Skip to content

Instantly share code, notes, and snippets.

@ffuentese
Last active August 11, 2018 21:56
Show Gist options
  • Save ffuentese/41615f1e654fa134167d7172cddde3cb to your computer and use it in GitHub Desktop.
Save ffuentese/41615f1e654fa134167d7172cddde3cb to your computer and use it in GitHub Desktop.
Pagination with Eloquent and Slim 3 using Bootstrap styles (PHP)

If you work with Slim you probably use Eloquent to retrieve and know that Eloquent is a ORM tool meant to be used within Laravel so its usage outside it is not very well documented.

if you want your query to include pagination you use:

$yourquery->links(); 

What if your Bootstrap version doesn't match Eloquent Pagination's? Support for Bootstrap 3/4 is built in however, Bootstrap 4 is not enabled in Pagination 5.2 at least.

To enable that you'd have to add an instance of the Bootstrap4Presenter.

$yourquery->links(new \Illuminate\Pagination\BootstrapFourPresenter($yourquery));

And that's it! It's hinted in Laravel's documentation but the info in there is not meant for non Laravel users. It took me a while to figure it out so I thought I'd share it with more people. Hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment