Skip to content

Commit 43c1c03

Browse files
committed
Creating Layout for Multiple Views
1 parent 810fa93 commit 43c1c03

File tree

6 files changed

+58
-17
lines changed

6 files changed

+58
-17
lines changed

app/Http/Controllers/MainController.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,14 @@ public function index($value)
1010
{
1111
return view('main', [ 'value'=> $value ]);
1212
}
13+
14+
public function page2($value)
15+
{
16+
return view('page2', [ 'value'=> $value ]);
17+
}
18+
19+
public function page3($value)
20+
{
21+
return view('page3', [ 'value'=> $value ]);
22+
}
1323
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>Document</title>
8+
</head>
9+
<body>
10+
<p>Text from the layout (TOP)</p>
11+
12+
<hr>
13+
14+
@yield('content')
15+
16+
<hr>
17+
18+
<p>Text from the layout (BOTTOM)</p>
19+
20+
</body>
21+
</html>

resources/views/main.blade.php

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8">
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7-
<title>Document</title>
8-
</head>
9-
<body>
10-
1+
@extends('layouts.main_layouts')
2+
3+
@section('content')
114
<h1>Welcome View and Blade!</h1>
125
<hr>
13-
<h3>The value is: <?= $value ?> </h3>
14-
</hr>
15-
16-
17-
</body>
18-
</html>
6+
<!-- <h3>The value is: <?= $value ?> </h3> -->
7+
<h3>The value is: {{ $value }} </h3>
8+
@endsection

resources/views/page2.blade.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@extends('layouts.main_layouts')
2+
3+
@section('content')
4+
<h1>Welcome View and Blade!</h1>
5+
<hr>
6+
<!-- <h3>The value is: <?= $value ?> </h3> -->
7+
<h3>Page 2</h3>
8+
<h3>The value is: {{ $value }} </h3>
9+
@endsection

resources/views/page3.blade.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@extends('layouts.main_layouts')
2+
3+
@section('content')
4+
<h1>Welcome View and Blade!</h1>
5+
<hr>
6+
<!-- <h3>The value is: <?= $value ?> </h3> -->
7+
<h3>Page 3</h3>
8+
<h3>The value is: {{ $value }} </h3>
9+
@endsection

routes/web.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@
1515
echo 'About us';
1616
});
1717

18-
Route::get('/main/{value}', [MainController::class, 'index']);
18+
Route::get('/main/{value}' , [MainController::class, 'index']);
19+
Route::get('/page2/{value}', [MainController::class, 'page2']);
20+
Route::get('/page3/{value}', [MainController::class, 'page3']);

0 commit comments

Comments
 (0)