-
-
Save ericlbarnes/5771365 to your computer and use it in GitHub Desktop.
@foreach (array_slice($posts->toArray(), 0, 5) as $post) | |
<h1>{{ $post['title'] }}</h1> | |
@endforeach |
In my case I have One album Music with 2 discs. Each Disc 14 musics and musics came from same table music. I share with this just with the model and one single consult.. Thanks a lot its very helpful for me.
This is great. Thank you.
Perfect :) Thanks
Can you do this for an array that gets loaded from the translation files?
For example:
@foreach(trans('pages/team.team') as $teamMember)
// Do something
@endforeach
But what if I need just the first 4 or 5?
->take(20)->get();
Just needed this for a dashboard view where we need the same data in different places, just modified a bit by limiting what is shown. Thanks for the solution, worked perfectly!
@foreach ($posts->slice(0, 5) as $post)
<h1>{{ $post->title }}</h1>
@endforeach
It works perfect for me.
@foreach ($posts->take(5) as $post)
<h1>{{ $post->title }}</h1>
@endforeach
is much cleaner, and works great
Yes sir ;) @ron4stoppable
@foreach($skills->user->take(5) as $user)
this one is great
@foreach (array_slice($data, 0, 4) as $content)
thanks
Perfect