本文整理匯總了PHP中app\Location::select方法的典型用法代碼示例。如果您正苦於以下問題:PHP Location::select方法的具體用法?PHP Location::select怎麽用?PHP Location::select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Location
的用法示例。
在下文中一共展示了Location::select方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: newPosts
public function newPosts(Request $request)
{
$lattitude = $request->input('lattitude');
$longitude = $request->input('longitude');
$radius = 10;
$posts = Location::select(DB::raw("locations.post_id,\n ( 6371 * acos( cos( radians(?) ) *\n cos( radians( lattitude ) )\n * cos( radians( longitude ) - radians(?)\n ) + sin( radians(?) ) *\n sin( radians( lattitude ) ) )\n ) AS distance, posts.message, posts.user_id, users.id, users.name, users.user_name"))->join('posts', 'posts.id', '=', 'locations.post_id')->join('users', 'users.id', '=', 'posts.user_id')->having("distance", "<", $radius)->orderBy("posts.created_at", 'desc')->setBindings([$lattitude, $longitude, $lattitude])->distinct()->get();
return response()->json($posts);
}
示例2: mapListings
public function mapListings()
{
$listingInfo = Listing_Info::where('is_active', '=', 1)->get();
$num = Listing_Info::where('is_active', '=', 1)->count();
$location = Location::select('city', 'country')->groupBy('city')->get();
if (Auth::check()) {
$savedSearch = Saved_Search::where('user_id', '=', Auth::user()->user_id)->get();
} else {
$savedSearch = null;
}
return view('mapListing', compact('listingInfo', 'location', 'savedSearch'), compact('num'));
}