2 months ago

Get the maximum number of relationship of collection

Posted 2 months ago by timtom


I have a question, i got a collection by ->get() eloquent query. I need to know the maximum of relationship possible for elements in my collection.

I have multiples invoices, and i would like to know the maximum of payments done for one invoices.

I think a solution by doing map function and parse raw by raw and take the count of relationship each time and keep the maximum, but i think this is not really optimized.

Do you have an idea ?

Please sign in or create an account to participate in this conversation.