Evan McMahon Evan McMahon - 2 years ago 72
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?

Answer Source

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;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download