laravel paginate raw sql

Solutions on MaxInterview for laravel paginate raw sql by the best coders in the world

showing results for - "laravel paginate raw sql"
Lucky
26 Aug 2020
1$items = DB::table('team')   
2    ->selectRaw('SELECT *,earth_distance(ll_to_earth(team.lat, team.lng), ll_to_earth(23.1215939329,113.3096030895)) AS distance')
3    ->whereRaw('earth_box(ll_to_earth(23.1215939329,113.3096030895),1000) @> ll_to_earth(team.lat, team.lng)')
4    ->paginate(10);
5
6foreach($items as $item) {
7    echo $item->distance;
8}
similar questions
queries leading to this page
laravel paginate raw sql