You should let the database handle all the filtering and sorting, it is faster and uses less memory than doing it in php.
That being said, can you give an example of the data and the desired result?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I need to form a query but planning it out and still can not seem to think a way to do it.
User has Many Subscription
So i need to find all User(s) who's last active subscription is older than a year. Subscription have. starts_on and expires_on fields to use
Something like orderBy expires_on DESC and then filter thru the collection to return if older than a year?
But probably not user might have a subscription currently not expired so i need to remove that user from the list.
If all of the users subscription are all less than a year remove from the list.
It's more complicated than it seems, or i cant seem to get the query in theory correct.
Any ideas?
Please or to participate in this conversation.