Laravel 4 style paginator with HTML

Submitted by moon0326 - 9 years ago

I don't personally use it, but some might find it useful. Laravel 5 paginator accepts a custom presenter for the paginator. In case you don't want to create a class or want to edit HTML directly, try the following trick.

# Create paginator.blade.php in your views directory. Copy and paste the content from

http://laravel.io/bin/xKm1K

# Create a presenter class that extends BootstrapThreePresenter (comes with L5)

namespace App;

use Illuminate\Pagination\BootstrapThreePresenter;

class HtmlBootstrapThreePresenter extends BootstrapThreePresenter
{
    public function render($viewName = 'paginator')
    {
        return view($viewName, [
            'paginator' => $this->paginator,
            'window' => $this->window,
        ]);
    }
}

# Usage

$user = User::paginate(15);
paginator = new App\HtmlBootstrapThreePresenter($user);

return view('your-own-view', ['paginator'=>$paginator]);

# in your view
$paginator->render();