Answer the question
In order to leave comments, you need to log in
Why doesn't Laravel sort() work?
It is necessary to display dialogs, while the essence of chats, as such, is not present. There are just messages in which sender_id and receiver_id. Now you need to display a list of chats. Then I came across a problem that it is not possible to sort users by the latest message, tell me what is wrong with the code?
$users = $users->sort(function ($user){
return $user->lastMessage->created_at->toDateTimeString();
});
Answer the question
In order to leave comments, you need to log in
Of course you can. You do a nested iteration of arrays through foreach or whatever is more convenient for you. Add the check if field_with_brand_name === Ferroz to the enumeration, if true, then add the data to the resulting array.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question