laravel table pagination code example
Example 1: paginate relationship laravel7
$category = Category::first();
$apps = $category->apps()->paginate(10);
return view('example', compact('category', 'apps'));
Example 2: laravel paginate raw sql
$items = DB::table('team')
->selectRaw('SELECT *,earth_distance(ll_to_earth(team.lat, team.lng), ll_to_earth(23.1215939329,113.3096030895)) AS distance')
->whereRaw('earth_box(ll_to_earth(23.1215939329,113.3096030895),1000) @> ll_to_earth(team.lat, team.lng)')
->paginate(10);
foreach($items as $item) {
echo $item->distance;
}
Example 3: paginate relationship laravel7
@foreach ($apps as $app)
{{ $app->id }}
@endforeach
{!! $apps->render() !!}
Example 4: laravel pagination
{{ $users->withQueryString()->links() }}
Example 5: laravel pagination
DB::table('users') -> paginate(15)