laravel pagination having raw query not working

Solutions on MaxInterview for laravel pagination having raw query not working by the best coders in the world

showing results for - "laravel pagination having raw query not working"
Alberto
23 Sep 2018
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}
Francisco
29 Mar 2020
1        $curPage = \Illuminate\Pagination\Paginator::resolveCurrentPage();
2        $total = $model->get()->count();
3        $items = $model->forPage($curPage, $showPerPag)->get();
4        $paginated = new \Illuminate\Pagination\LengthAwarePaginator($items, $total, $showPerPage, $curPage, ['path' => request()->url(), 'query' => request()->query()]);
5
Francisco
04 Sep 2017
1// This works as expected       
2
3		$curPage = \Illuminate\Pagination\Paginator::resolveCurrentPage();
4        $total = $model->get()->count();
5        $items = $model->forPage($curPage, $showPerPag)->get();
6        $paginated = new \Illuminate\Pagination\LengthAwarePaginator($items, $total, $showPerPage, $curPage, ['path' => request()->url(), 'query' => request()->query()]);
7
similar questions