Evan McMahon Evan McMahon - 6 months ago 3x
PHP Question

Laravel - force pagination links to show even if there is only a single page

I'm working with laravel pagination, however I wish to display the pagination links regardless of if there is only a single page, or multiple pages.

Currently, it is only displayed if there are multiple pages of results.

Eloquent Call

$products = Product::where('username', Sentry::getUser()->username)->paginate(25);

and then displayed in the view using

{!! $products->links() !!}

How can I force Laravel to display it when there is only a single page?


There is no easy way, because it's hardcoded. However you could extend SimpleBootstrapThreePresenter and override hasPages() method:

public function hasPages()
    return true;

Instead of:

public function hasPages()
    return $this->paginator->hasPages() && count($this->paginator->items()) > 0;