How access to $loop variable in nested foreach blead

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


You could use $loop->parent to access the parent loop of the current loop.

Tags:

Laravel

Blade