Jishad P Jishad P - 2 years ago 150
PHP Question

Laravel Manual Pagination Error

I have a issue related to Laravel5 Manual Pagination.
I need to process an array of query builder result and some other arrays and make a pagination for that.


public function searchCategory($id){
$arr = DB::table('business_businesscatagories')->lists('fk_business_id');
return Paginator::make($arr, count($arr), 2);


use Illuminate\Pagination\LengthAwarePaginator as Paginator;

But I got the error like below..

FatalErrorException in IndexController.php line 122:
Call to undefined method Illuminate\Pagination\LengthAwarePaginator::make()

How can I solve this issue....

Answer Source

I examined Illuminate\Pagination\LengthAwarePaginator and was able to confirm that it doesn't have make method.

However you can achieve this by using its constructor method.

__construct(mixed $items, int $perPage, int|null $currentPage = null, array $options = array())

Since you already have the correct namespace specified:

use Illuminate\Pagination\LengthAwarePaginator as Paginator;

You could simply do this:

$paginator = new Paginator($items, $total, $per_page);

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download