# Master layout (ok)

![](https://1957079826-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MCBeDUD-PK_RF-YgJRe%2F-MCQ1d_VEdkMdDi8FKkI%2F-MCQ1u7a8z5NcbnIRwXB%2FScreenshot_3.png?alt=media\&token=d754a294-b53d-4ffa-a86d-33b311705b1e)

```
<?php
namespace App\Http\Controllers;
use App\Product;
use Illuminate\Http\Request;

class Test extends Controller {
  /**
   * Display a listing of the resource.
   *
   * @return \Illuminate\Http\Response
   */
  public function index() {
    return view('child');
  }
}
```

![](https://1957079826-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MCBeDUD-PK_RF-YgJRe%2F-MCQ1d_VEdkMdDi8FKkI%2F-MCQ25YDqM4FYm2JFs0j%2FScreenshot_5.png?alt=media\&token=04c37f16-ea81-4b74-8b42-f5c8bd3dadca)

```
<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});
Route::resource('products','ProductController');
Route::resource('test','Test');
```

## Dữ liệu cố định:

@yield từ khóa giữ chỗ cố định.

```
<!-- Stored in resources/views/layouts/app.blade.php -->
<html>
    <head>
        <title>App Name - @yield('title')</title>
    </head>
    <body>
        @section('sidebar')
            This is the master sidebar.
        @show
        <div class="container">
            @yield('content')
        </div>
    </body>
</html>
```

![](https://1957079826-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MCBeDUD-PK_RF-YgJRe%2F-MCPtEc7jgYUHhv6v7_8%2F-MCQ19HBTOZC51jV5YZ7%2FScreenshot_2.png?alt=media\&token=384d101e-0343-48ca-a12a-5f9624fab702)

![](https://1957079826-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MCBeDUD-PK_RF-YgJRe%2F-MCQ292KiK9bbzj2bAdT%2F-MCQ2D_IIOrWwk3534Ro%2FScreenshot_4.png?alt=media\&token=940329fa-b66a-4fdd-a013-f50cafed33b1)

## Dữ liệu thay đổi @section && @show dùng mở rộng

> &#x20;@section Lệnh này cũng chấp nhận một giá trị mặc định là tham số thứ hai của nó. Giá trị này sẽ được hiển thị nếu phần được mang lại không được xác định:`@yield`

```
<!-- Stored in resources/views/layouts/app.blade.php -->
<html>
    <head>
        <title>App Name - @yield('title')</title>
    </head>
    <body>
        @section('sidebar')
            This is the master sidebar.
        @show
        <div class="container">
            @yield('content')
        </div>
    </body>
</html>
```

```
@extends('layouts.app')

@section('title', 'Page Title')

@section('sidebar')
  @parent
  <p>This is appended to the master sidebar.</p>
@endsection

@section('content')
  <p>This is my body content.</p>
@endsection
```

![](https://1957079826-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MCBeDUD-PK_RF-YgJRe%2F-MCQ2GrEt0DKSbMMkZNT%2F-MCQ2tzeK7PPtJopv0Tu%2FScreenshot_6.png?alt=media\&token=0a5f2aac-8e9e-456c-8620-23c18f13c590)
