06.10.2016 Views

laravel-5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Blade Templates 177<br />

1 <br />

2 @hasSection ('title')<br />

3 @yield('title') - App Name<br />

4 @else<br />

5 App Name<br />

6 @endif<br />

7 <br />

Loops<br />

In addition to conditional statements, Blade provides simple directives for working with PHP’s<br />

supported loop structures. Again, each of these directives functions identically to their PHP<br />

counterparts:<br />

1 @for ($i = 0; $i < 10; $i++)<br />

2 The current value is {{ $i }}<br />

3 @endfor<br />

4<br />

5 @foreach ($users as $user)<br />

6 This is user {{ $user->id }}<br />

7 @endforeach<br />

8<br />

9 @forelse ($users as $user)<br />

10 {{ $user->name }}<br />

11 @empty<br />

12 No users<br />

13 @endforelse<br />

14<br />

15 @while (true)<br />

16 I'm looping forever.<br />

17 @endwhile<br />

When using loops you might need to end the loop or skip the current iteration:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!