-
Notifications
You must be signed in to change notification settings - Fork 11.5k
Closed
Description
After upgrading to Laravel 5.2.41, I'm getting Method load does not exist exception while trying to call load() method in LengthAwarePaginator collection.
I found out Eloquent Builder.php paginate() method sets empty array if total count of the result set is zero. So LengthAwarePaginator converts the empty array into \Illuminate\Support\Collection which does not have load() method.
public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
{
$page = $page ?: Paginator::resolveCurrentPage($pageName);
$perPage = $perPage ?: $this->model->getPerPage();
$query = $this->toBase();
$total = $query->getCountForPagination();
$results = $total ? $this->forPage($page, $perPage)->get($columns) : [];
return new LengthAwarePaginator($results, $total, $perPage, $page, [
'path' => Paginator::resolveCurrentPath(),
'pageName' => $pageName,
]);
}
Kindly return Eloquent empty collection instead of an empty array, so eager loading won't fail.
Metadata
Metadata
Assignees
Labels
No labels