Because it's not coming from a pagination.
Hi Fluzo,
Assign to a variable and then run the foreach loop as follow:
$posts = $tema->posts()->paginate(5);
@foreach($posts as $post)
//make all you need with each $post object
@endforeach
Don't forget the closing tags for your blade foreach loop.
Hope it helps you.
codeATbusiness said:
Hi Fluzo,
Assign to a variable and then run the foreach loop as follow:
$posts = $tema->posts()->paginate(5); @foreach($posts as $post) //make all you need with each $post object @endforeach
Don't forget the closing tags for your blade foreach loop.
Hope it helps you.
That's correct, you should assign to a variable, but do so in your controller, not your view. Business logic should not be a view :)
ollieread said:
codeATbusiness said:
Hi Fluzo,
Assign to a variable and then run the foreach loop as follow:
$posts = $tema->posts()->paginate(5); @foreach($posts as $post) //make all you need with each $post object @endforeach
Don't forget the closing tags for your blade foreach loop.
Hope it helps you.
That's correct, you should assign to a variable, but do so in your controller, not your view. Business logic should not be a view :)
Yes ollieread, the better way could be a Repository to manage the relation between the Controller and the Data Layer.
Thanks for your comment.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community