Use the $loop variable in Blade foreach loops to access metadata about the loop

Use the $loop variable in Blade foreach loops to access metadata about the loop

A handy $loop object is available in Laravel Blade foreach loops. Super useful for controlling output based on the loop position ➰

Source dive for reference: https://github.com/laravel/framework/blob/8.x/src/Illuminate/View/Concerns/ManagesLoops.php

We're writing a book, you can get it for free here.