1@for ($i = 0; $i < 10; $i++)
2 The current value is {{ $i }}
3@endfor
4
5@foreach ($users as $user)
6 <p>This is user {{ $user->id }}</p>
7@endforeach
8
9@forelse ($users as $user)
10 <li>{{ $user->name }}</li>
11@empty
12 <p>No users</p>
13@endforelse
14
15@while (true)
16 <p>I'm looping forever.</p>
17@endwhile
1@foreach ($users as $user)
2 @if ($loop->first)
3 This is the first iteration.
4 @endif
5
6 @if ($loop->last)
7 This is the last iteration.
8 @endif
9
10 <p>This is user {{ $user->id }}</p>
11@endforeach
1// Create component in terminal using :
2 php artisan make:component MyComponent
3
4// 2 files will be made :
5// * app\View\Components\MyComponent.php
6// - Handels functionality.
7// * resources\views\components\my-component.blade.php ()
8// - Code snippet for component. Must be inside <div>...</div>.
9
10// Call component in any other blade file using :
11 <x-my-component />
12
13// Send hardcoded parameter :
14 <x-my-component name="Hello World!"/>
15
16// Send a php parameter :
17 <x-my-component :text="$message"/>
18