简体   繁体   中英

How does pagination work in Laravel 5?

I created pagination by writing

$users = User::paginate(25);

Then to display the links, I used the following command,

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

As the command given below no longer works in Laravel 5

{{$users->links()}}

{!! $users->render() !!} {!! $users->render() !!} displays the pagination links in the view but there is a slight issue with the links.

This link it generates is like this

http://localhost/laravel/public/users/?page=2

How can I change the generated link to something like this

http://localhost/laravel/public/users?page=2

ie to remove the slash(/) after users in the url?

The reason for this is that the url with slash after users fails.

Any help regarding pagination will be greatly appreciated.

Thanks

Please try the following $users->setPath('')->render(); . I had a similar situation and this fixed the issue for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM