1@foreach ($users as $user)
2 <p>This is user {{ $user->id }}</p>
3@endforeach
4
5@forelse ($users as $user)
6 <li>{{ $user->name }}</li>
7@empty
8 <p>No users</p>
9@endforelse
10
1public function index()
2{
3 $posts = Post::all();
4 return view('Pages.welcome')->with('posts', $posts);
5}
6
1@if(count($posts) > 1)
2 @foreach($posts as $post)
3 <h2><a href="/posts/{{$post->id}}">{{$post->title}}</a></h2>
4 @endforeach
5@else
6 </p>no posts found</p>
7@endif
8
1 /**
2 * Compile the for-each statements into valid PHP.
3 *
4 * @param string $expression
5 * @return string
6 */
7 protected function compileForeach($expression)
8 {
9 preg_match('/\( *(.*) +as *(.*)\)$/is', $expression, $matches);
10
11 $iteratee = trim($matches[1]);
12
13 $iteration = trim($matches[2]);
14
15 $initLoop = "\$__currentLoopData = {$iteratee}; \$__env->addLoop(\$__currentLoopData);";
16
17 $iterateLoop = '$__env->incrementLoopIndices(); $loop = $__env->getLastLoop();';
18
19 return "<?php {$initLoop} foreach(\$__currentLoopData as {$iteration}): {$iterateLoop} ?>";
20 }
21
22
23 /**
24 * Compile the for-else statements into valid PHP.
25 *
26 * @param string $expression
27 * @return string
28 */
29 protected function compileForelse($expression)
30 {
31 $empty = '$__empty_'.++$this->forElseCounter;
32
33 preg_match('/\( *(.*) +as *(.*)\)$/is', $expression, $matches);
34
35 $iteratee = trim($matches[1]);
36
37 $iteration = trim($matches[2]);
38
39 $initLoop = "\$__currentLoopData = {$iteratee}; \$__env->addLoop(\$__currentLoopData);";
40
41 $iterateLoop = '$__env->incrementLoopIndices(); $loop = $__env->getLastLoop();';
42
43 return "<?php {$empty} = true; {$initLoop} foreach(\$__currentLoopData as {$iteration}): {$iterateLoop} {$empty} = false; ?>";
44 }
45
1 public function __construct()
2{
3 $this->middleware('auth');
4}
5
6/**
7 * Show the application dashboard.
8 *
9 * @return \Illuminate\Contracts\Support\Renderable
10 */
11public function index()
12{
13 return view('home');
14}
15
1public function index()
2{
3 $posts = Post::all();
4 return view('posts.index')->with('posts', $posts);
5}
6
1 Route::get('/', 'PageController@index');
2 Route::get('/welcome','PageController@Welcome');
3 Route::get('/services', 'PageController@services');
4 Route::get('/register', 'PageController@register');
5 Route::get('/Create', 'PageController@Create');
6 Route::get('/search', 'PageController@search');
7 Route::get('/payment', 'PageController@Payment');
8
9
10
11 Route::resource('posts', 'PostsController');
12 Route::resource('search', 'SearchController');
13 Route::resource('reviews', 'ReviewsController');
14