in eloquent i'm running this query,
$news = Post::where('status','=',1)
->orderBy('id', 'Desc')
->limit(5)
->get();
the query is getting last 5 records from news table? the issue i'm facing is in blade? the first record of the query should be featured news where in blade i'm using bootstrap to get a big image covering half of the row (col-md-6) and the reset of the posts should be presented in the other half of the row element separated in 4 cells (col-md-3 for each).
how can i solve this problem by separating the query and take first post to show in featured area and loop the rest of the 4 remaining posts in smaller cells.
im using this currently
@foreach($news as $item)
@if ($loop->first)
// here is the featured post
@else
// these are the remaining posts
@endif
@endforeach
the loop above is separating the first post as featured but it still looping the 5 records in the query in the smaller cells.
so basically i have the featured post repeated with the rest of the posts.
Example : 5 queries first is featured the reset are not feature, the solution above is returning
@foreach($news as $item)
@if ($loop->first)
// featured post is returned correctly
@else
// here? blade is looping the entire query including featured post, (featured post is repeated in this area also)
@endif
@endforeach
is there is a solutions so i can loop the remaining last 4 records only