When to use Blade's loop variable, and when not to
Laravel is always giving us little helpers.
One of which is Blade’s @foreach that gives you a $loop variable.
Inside the loop you get things like $loop->index and $loop->iteration, plus the two I want to talk about today: $loop->first and $loop->last.
first and last are boolean values that tell you if this is the first iteration or the last iteration of the loop.
Pretty self-explanatory.
But far too many times I see people abusing these for style - when they should be for flow control.