I have the following query:
Post::whereIn('id', [3, 4, 1, 2])->paginate(10);
And the result I get is in the following order (ids I mean):
1, 2, 3, 4 ...
Is it possible to somehow get the result in the order of how ids are passed to the query?
I have the following query:
Post::whereIn('id', [3, 4, 1, 2])->paginate(10);
And the result I get is in the following order (ids I mean):
1, 2, 3, 4 ...
Is it possible to somehow get the result in the order of how ids are passed to the query?
Probabyl you need to sort then in the query like this:
Post::whereIn('id', [3, 4, 1, 2])->orderBy('id')->paginate(10);
read laravel doc from this link for whereIn() you didnt make any objects of your POST model make an object and work with it, its better this way