Hi everyone,
I've started playing with laravel 5 and I'm a little confused by the paginator presenter. I want to display a simplePaginator at the bottom of my page (which is incredibly easy if you want the default bootstrap one) but I want to add a text to the buttons to have something like "< Previous" and "next >" instead of just "<" and ">".
I manage to get what I want but it seems a little convoluted so I think I may have missed something.
What I had to do is create a new PaginatorPresenter class which extends SimpleBootstrapThreePresenter, and overrides the render() method by a copy/paste of the original one except I pass "< Previous" and "Next >" as arguments to $this->getPreviousButton() and $this->getNextButton().
<?php
namespace App;
use Illuminate\Pagination\SimpleBootstrapThreePresenter;
class PaginationPresenter extends SimpleBootstrapThreePresenter
{
public function render()
{
if ($this->hasPages())
{
return sprintf(
'<ul class="pager">%s %s</ul>',
$this->getPreviousButton("< Previous"),
$this->getNextButton("Next >")
);
}
return '';
}
}
then I can get my HTML by doing :
$articles->render(new \App\PaginationPresenter($articles))
Is there a simpler way to do this ? Like maybe setting a default paginator for all the application ? Or sending just the strings you want to the default paginator ?
Thanks.