BÀI 6 : BLADING TEMPLATE I Blading Template master.blade.php (parent)
Khoa Phạm - @yield('title') @section('sidebar') This is the master sidebar. @show
@yield('content')
layout.blade.php (child) @extends('layouts.master') @section('title', 'Lập Trình Laravel ')
@section('sidebar') @parent
This is appended to the master sidebar.
@stop @section('content')
This is my body content.
@stop
II Echo Data Qu ốc Tuấn'; ?>
Mã lệnh
Hi n thị
Chào bạn {{ $name }}
Chào bạn
Quốc Tuấn
Chào bạn {!! $name !!}
Chào bạn Quốc Tuấn
III Mệnh đề điều kiện @if (count($records) === 1) I have one record! @elseif (count($records) > 1) I have multiple records! @else I don't have any records! @endif
{{ isset($name) ? $name : 'Quốc Tuấn ' }}
{{ $name or 'Quốc Tuấn ' }}
IV Vòng lặp For @for ($i = 0;$i < 10;$i++ ) Giá trị : {{ $i }} @endfor
While @while ($i <= 5)
Lặp 5 lần .
@endwhile
Foreach @foreach ($users as $user)
{{ $user->id }}
@endforeach
V Nhúng Sub View @include('layout.sub')
@include('layout.sub',['content'=>'Đây là nộ i dung trong sub view'])
VI Ghi chú {{-- Đây là dòng chú thích trong Blading Template --}}