Answer the question
In order to leave comments, you need to log in
Laravel Find method how to use it or another?
I pass an array of sorted id to the find method, it also returns models sorted from the smallest id . Which breaks my whole logic. How would you recommend fixing this?
I write a pure sql query and get id . Perhaps you can somehow immediately connect it with the base by d?
Answer the question
In order to leave comments, you need to log in
$ids = [12, 2, 3];
$users= \App\User::find($ids)->sortBy(function ($user) use ($ids) {
return array_search($user->getKey(), $ids);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question