Last active
January 20, 2021 13:37
-
-
Save Alexander-Pop/a7516cd12b0e7919803b9baa75fb4172 to your computer and use it in GitHub Desktop.
Laravel 8 - blade loops #laravel #blade #laravel-loop #foreach
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@if ($products->count()) | |
@foreach($products as $product) | |
<div @if ($loop->name) class="foo-class" @endif> | |
//$loop was auto added ($loop->first, $loop->last, $loop->odd, $loop->even, $loop->interation, $loop->index) | |
somethinh | |
</div> | |
@if ($product->price > 2000) @breake @endif | |
@endforeach | |
@else | |
No products found | |
@endif | |
//https://dev.to/pratham0182/foreach-vs-forelse-3c9m | |
//https://laravel.com/docs/8.x/blade#the-loop-variable | |
//https://laravel-news.com/laravel-blade-each |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment