There is an array of ID's posts, sorted by the number of stars set:

[0 => 469 1 => 470 2 => 91 3 => 11] 

When I try to execute the query:

 \DB::table('table') ->whereIn('id', $id) ->take($count) ->paginate(12); 

The array is automatically sorted, i.e. ID become in ascending order (ASC, the meaning of the output of the most popular disappears).

How can I make such a request with further pagination?

  • From where does this array come from? If by request it would be better to take the information right away - Yaroslav Molchan
  • I take the array from the table that stores the number of likes and the name of the model, then I pull out the ID of the posts of the desired model in descending order of likes. - Sazhin

1 answer 1

In the query designer, you can freely set the field and order for sorting:

 ->orderBy('имя_столбца_в_котором_количество_звёзд', 'desc')