samedi 20 février 2016

Laravel 5.1 paginator doesn't display when result set is less than paginator?

When I have a paginator that is greater than the number of results in my query no links are displayed i.e. the paginator doesn't render anything. Which is fine because there are no links for the user to page through. However what if you still want to display the paginator which displays previous, first page, and next link but obviously disabled. How can you achieve that?

public function index()
{
    // only 1 user in table
    $users = DB::table('users')->paginate(15);

    return view('user.index', ['users' => $users]);
} 

If there is only 1 user no links are displayed

<div class="container">
 @foreach ($users as $user)
    {{ $user->name }}
 @endforeach
</div>

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



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire