本文整理汇总了PHP中app\City::with方法的典型用法代码示例。如果您正苦于以下问题:PHP City::with方法的具体用法?PHP City::with怎么用?PHP City::with使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\City
的用法示例。
在下文中一共展示了City::with方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* 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);
}
示例2: index
/**
* 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]);
}
示例3: index
/**
* 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);
}
示例4: showCustomerAccount
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');
}
}
示例5: index
/**
* 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);
}
示例6: city
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]);
}
示例7: getCitiesWithUserPaginate
/**
* Get Citys with user paginate.
*
* @param integer $n
* @return collection
*/
public function getCitiesWithUserPaginate($n)
{
$citys = City::with('user')->latest()->simplePaginate($n);
return $citys;
}