how to use laravel 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 multiple paginate

# use default 'page' for this
$collection1 = Model::paginate(20);

# use custom 'other_page' for this
$collection2 = Model2::paginate(20);
$collection2->setPageName('other_page');

Example 3: laravel pagination

{{ $users->withQueryString()->links() }}

Example 4: paginate relationship laravel7

@foreach ($apps as $app)
    {{ $app->id }}
@endforeach

{!! $apps->render() !!}

Tags:

Sql Example