varovas's avatar

How to rearrange Eloquent query array in Laravel 5.3?

Hi guys, can anyone give me a tip, how to rearrange array, or give other technique how to get my featured posts on top of the page without losing pagination?.

My code in controller:

$posts = Post::latest()->paginate(10);

And I get post list like this:

  1. POST
  2. POST
  3. POST
  4. FEATURED POST
  5. POST
  6. POST
  7. FEATURED POST
  8. FEATURED POST
  9. POST

I want them to list like this:

  1. FEATURED POST
  2. FEATURED POST
  3. FEATURED POST
  4. POST ...
  5. POST

How can I make that kind of a result?

0 likes
0 replies

Please or to participate in this conversation.