本文整理汇总了PHP中app\City::whereId方法的典型用法代码示例。如果您正苦于以下问题:PHP City::whereId方法的具体用法?PHP City::whereId怎么用?PHP City::whereId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\City
的用法示例。
在下文中一共展示了City::whereId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cityListForAutoComplete
/**
* Make the list for json autocomplete search
*
* @return string
*/
public static function cityListForAutoComplete()
{
$cities = City::select(['id', 'name'])->orderBy('name')->get()->transform(function ($city) {
return $city['name'] = $city['name'] . ' (' . City::whereId($city['id'])->first()->province->name . ')';
});
return "var cities = " . $cities->toJson();
}
示例2: showCity
/**
* Sbow all adds in a city
*
* @param $slug
* @param $id
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function showCity($slug, $id)
{
$city = City::whereId($id)->first();
$categories = ClassifiedCategory::orderBy('id')->get();
$items = Classified::where('city_id', $id)->orderBy('publish_at', 'desc')->get();
return view('classifieds.classified_city', compact('city', 'categories', 'items'));
}