Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] Create custom Collection also on empty page #16547

Merged
merged 1 commit into from
Nov 25, 2016
Merged

[5.3] Create custom Collection also on empty page #16547

merged 1 commit into from
Nov 25, 2016

Conversation

vlakoff
Copy link
Contributor

@vlakoff vlakoff commented Nov 25, 2016

Follow-up to #16528. Makes sense that Eloquent Builder passes the same class to LengthAwarePaginator whether the page is empty or not.

This would have worked too:

$results = $this->forPage($page, $perPage)->get($columns);

Though in doubt, I kept the optimization from #14188.


The change in Query Builder is not mandatory because LengthAwarePaginator already converts to a base Collection, but it's more straightforward this way.

@taylorotwell taylorotwell merged commit bd3eb57 into laravel:5.3 Nov 25, 2016
@@ -1663,7 +1663,7 @@ public function paginate($perPage = 15, $columns = ['*'], $pageName = 'page', $p

$total = $this->getCountForPagination($columns);

$results = $total ? $this->forPage($page, $perPage)->get($columns) : [];
$results = $total ? $this->forPage($page, $perPage)->get($columns) : collect();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vlakoff should it not be a new \Illuminate\Database\Eloquent\Collection ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the query builder, not eloquent.

@vlakoff vlakoff deleted the empty-pages branch November 25, 2016 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants