Categories
Laravel check for even odd and last?
Hello ! Tell me, there is a cycle in the blade how to make the counter shorter, check the counter for even / odd and if the counter value is the last.
@foreach($acts as $key => $value) @endforeach
Answer the question
In order to leave comments, you need to log in
In recent versions of Laravel, there is a $loop variable in the loop:
@if ($loop->last) This is the last iteration. @endif
@if ($loop->index % 2 == 0) Четное @else Нет @endif
Didn't find what you were looking for?
Ask a Question
731 491 924 answers to any question