laravel paginator obje code example

Example 1: laravel pagination

// in, AppServiceProvider -> boot() - set: 
Paginator::useBootstrap();  // for compatibility with bootstrap

// in controller 
$storage = Model::paginate(10);

// in view 
{!! $storage->links() !!}

Example 2: access paginator object attribute in laravel

$paginator = tap($this->items()->where('position', '=', null)->paginate(15),function($paginatedInstance){
    return $paginatedInstance->getCollection()->transform(function ($value) {
        return $value;
    });
});

Tags:

Php Example