@foreach($last_articles->chunk(3) as $row)
@foreach($row as $last_article)
@if($loop->index!=0) {{"in $loop"}} @endif
@endforeach
@if($loop->index!=0) {{"out $loop"}} @endif
@endforeach
how access to $loop of any of foreach, that was used in code?
You could use $loop->parent
to access the parent loop of the current loop.
In my case (Laravel 6.8) $loop->parent
looks like this
[
{"iteration":1,"index":0,"remaining":1,"count":2,"first":true,"last":false,"odd":true,"even":false,"depth":1,"parent":null},
{"iteration":2,"index":1,"remaining":0,"count":2,"first":false,"last":true,"odd":false,"even":true,"depth":1,"parent":null}
]
to access the parent index $loop->parent->index
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With