Reputation: 4285
I seem to be unable to manually create an instance of the paginator.
use Illuminate\Pagination\Paginator;
class Blah {
public function index(Paginator $paginator)
{
// Build array
$var = $paginator->make($array, $count, 200);
return $var;
}
}
From here I'm just getting Unresolvable dependency resolving [Parameter #0 [ <required> $items ]] in class Illuminate\Pagination\Paginator
Upvotes: 6
Views: 19790
Reputation: 6518
To manualy paginate items in Laravel you should instantiate the Illuminate\Pagination\Paginator
class like this:
// array of items
$items = [ 'a' => 'ana', 'b' => 'bla', 'c' => 'cili' ];
// items per page
$perPage = 2;
// let paginator to regonize page number automaticly
// $currentPage = null;
// create paginator instance
$paginate = new Paginator($items, $perPage);
Upvotes: 2
Reputation: 455
There is no more make() method in laravel 5. You need to create an instance of either an Illuminate\Pagination\Paginator
or Illuminate\Pagination\LengthAwarePaginator
. Take a look at documentation page, Creating A Paginator Manually part
http://laravel.com/docs/master/pagination
I guess it'll look something like this:
use Illuminate\Pagination\Paginator;
class Blah {
public function index()
{
// Build array
$array = [];
return new Paginator($array, $perPage);;
}
}
Also check this answer.
Upvotes: 16