jeudi 30 avril 2020

Laravel custom pagination exception | Undefined property $pageName

Error message :

Undefined property: Illuminate\Pagination\LengthAwarePaginator::$pageName

I am creating pagination from an array and following is the array.

$array =  [▼
  "A" => 1
  "B" => 2
  "C" => 3
  "D" => 4
  "E" => 5
]

And have the following code :

public function paginate($items, $perPage = 5, $page = null, $options = [])
{
  $page = $page ?: (Paginator::resolveCurrentPage() ?: 1);
  $items = $items instanceof Collection ? $items : Collection::make($items);
  return new LengthAwarePaginator($items->forPage($page, $perPage), $items->count(), $perPage, $page, $options);
}

and calling the above method like the following :

$data = $this->paginate($array);
return view('test', ['data' => $data]);

And in test view, I've the following to show pagination links:

<div> </div>

I've no idea what am I missing, I've checked quite a lot.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2yVfgtc
via IFTTT

Aucun commentaire:

Enregistrer un commentaire