-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Calling paginate() returns error #10
Comments
I did not look into pagination yet, I will try to add it today. |
Oh I see. Thanks. EDIT: Actually what I want to do requires |
Pagination was actually working already when I tried it.
Returned me 5 items, and pagination links. |
Interesting, no matter where I put the call to pagination method in the chain, it wouldn't work. |
Take and skip is working as well, those are tested by unittests. |
Can I see your chain? |
Yes they are working fine.
|
I was able to execute the following without any errors:
But when I look at your error message, the query builder started using the aggregation framework. Did you use any grouping or aggregation somewhere else or in the same query? |
Not to my knowledge. If I have, then I've used it without knowing. I have 2 weeks experience of PHP/Laravel. If you say it works, then it probably does and I've done something stupid. Off-topic: Since MongoDB can have arrays inserted into them, does this package support something like |
Yes, you can just use something like this:
|
I think we are thinking of slightly different arrays. I was thinking of having inserted:
into a field |
You can use this query for that:
Check 92754b8 |
Oh I see. So that does work. Thanks very much for your help. Much appreciated. |
How to conver to array when use pagination. |
…eject invalid array (mongodb#10) The Query\Builder::whereBetween() method can be used like this: whereBetween('date_field', [min, max]) whereBetween('date_field', collect([min, max])) whereBetween('date_field', CarbonPeriod) Laravel allows other formats: the $values array is flatten and the builder assumes there are at least 2 elements and ignore the others. It's a design that can lead to misunderstandings. I prefer to raise an exception when we have incorrect values, rather than trying to guess what the developer would like to do. Support for CarbonPeriod was fixed in Laravel 10: laravel/framework#46720 because the query builder was taking the 1st 2 values of the iterator instead of the start & end dates.
…eject invalid array (#10) The Query\Builder::whereBetween() method can be used like this: whereBetween('date_field', [min, max]) whereBetween('date_field', collect([min, max])) whereBetween('date_field', CarbonPeriod) Laravel allows other formats: the $values array is flatten and the builder assumes there are at least 2 elements and ignore the others. It's a design that can lead to misunderstandings. I prefer to raise an exception when we have incorrect values, rather than trying to guess what the developer would like to do. Support for CarbonPeriod was fixed in Laravel 10: laravel/framework#46720 because the query builder was taking the 1st 2 values of the iterator instead of the start & end dates.
Doing
User::paginate(1)
generates stack trace:The text was updated successfully, but these errors were encountered: