/** * Display the specified resource. * * @param int $id * * @return \Illuminate\Http\Response */ public function show($id) { $city = City::with('country')->findOrFail($id); $statusCode = 200; $response = ["city" => ['id' => $city->id, 'city' => $city->city, 'country_id' => $city->country_id, 'country' => $city->country->country]]; return response($response, $statusCode); }
/** * Display a listing of the resource. * * @return Response */ public function index() { //$countries = \App\Country::all()->lists('name','id'); //$states = \App\State::all()->lists('name','id'); $cities = \App\City::with('state')->get(); return response()->json($cities); return view('states.index', ['cities' => $cities]); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index($country_id) { $statusCode = 200; $response = ['cities' => []]; Country::findOrFail($country_id); $cities = City::with('country')->where('country_id', '=', $country_id)->get(); foreach ($cities as $city) { $response['cities'][] = ['id' => $city->id, 'city' => $city->city, 'country_id' => $country_id, 'country' => $city->country->country]; } return response($response, $statusCode); }
public function showCustomerAccount($id, $type) { //if($type=="Info"||$type=="Favorites"||$type=="Wishlist"){ $market_data = Market::with('category')->get(); $city = City::with('area')->get(); if (Auth::check()) { $id = Auth::user()->login_id; $user = User::where('id', $id)->with('member')->get(); return view('client.pages.account-page')->with('user', $user)->with('market_data', $market_data)->with('city', $city)->with('type', $type); } else { return redirect('/Market'); } }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index($country_id, $city_id) { $statusCode = 200; $city = City::with(['country'])->findOrFail($city_id); if ($city->country->id != $country_id) { throw new ModelNotFoundException(); } $languages = City::findOrFail($city_id)->language()->get(); foreach ($languages as $language) { $response['languages'][] = ['id' => $language->id, 'language' => $language->language]; } return response($response, $statusCode); }
public function city($country, $city) { $this_city = City::with('country')->where('city_slug', $city)->first(); $airlines = Flight::where('city_slug', $city)->where('scheduled_time', '>', Carbon::now()->subMonths(1))->where('codeshare', 0)->orderBy('airline', 'asc')->groupBy('airline')->get(); /* $arrivalflights = Arrival::where('scheduled_time','>',Carbon::now()->subMonths(1)) ->where('origin_city', $city) ->where('codeshare',0) ->groupBy('flight_number') ->get(); */ $arrivalflights = Flight::select(DB::raw('*, strftime("%H:%M %w",scheduled_time) as timeDay, strftime("%H:%M",scheduled_time) as time, strftime("%w",scheduled_time) as dayofweek'))->where('scheduled_time', '>', Carbon::now()->subWeeks(1))->where('city_slug', $city)->where('codeshare', 0)->where('arrival', 1)->orderBy('dayofweek', 'asc')->orderBy('time', 'asc')->groupBy('timeDay')->get(); $departureflights = Flight::select(DB::raw('*, strftime("%H:%M %w",scheduled_time) as timeDay, strftime("%H:%M",scheduled_time) as time, strftime("%w",scheduled_time) as dayofweek'))->where('scheduled_time', '>', Carbon::now()->subWeeks(1))->where('city_slug', $city)->where('codeshare', 0)->where('departure', 1)->orderBy('dayofweek', 'asc')->orderBy('time', 'asc')->groupBy('timeDay')->get(); $arrivals = Flight::with('country')->where('city_slug', $city)->where('codeshare', 0)->where('arrival', 1)->orderBy('scheduled_time', 'desc')->take(5)->get(); $departures = Flight::with('country')->where('city_slug', $city)->where('codeshare', 0)->where('departure', 1)->orderBy('scheduled_time', 'desc')->take(5)->get(); return view('pages.city')->with(['this_city' => $this_city, 'airlines' => $airlines, 'arrivalflights' => $arrivalflights, 'departureflights' => $departureflights, 'arrivals' => $arrivals, 'departures' => $departures]); }
/** * Get Citys with user paginate. * * @param integer $n * @return collection */ public function getCitiesWithUserPaginate($n) { $citys = City::with('user')->latest()->simplePaginate($n); return $citys; }