Sistema de Template do Laravel 5, que é o Blade
Criar uma pasta template ou layouts dentro da pasta views
Criar um template nesta pasta:
template1.blade.php
<!DOCTYPE html>
<html>
<head>
<title>{{$title or 'Curso de Laravel 5.3'}}</title>
</head>
<body>
@yeld('content')
</body>
</html>
Vamos usar o template acima na pasta home
Criar index.blade.php
@extends('site.template.template1')
@section('content')
<h1>Home page do site</h1>
{{$var1 or 'Não existe'}}
@endsection
Rodar código JavaScript/HTML
{!! $xss !!}
Controles no Template
@section('content')
@if ($var1 == '123')
É igual
@endif
@endsection
@for($i;$<10;$i++)
@foreach($posts as $post)
@forelse
Comentários
{{--
comentado
--}}
@php
@endphp
Includes
@include('site.includes.sidebar', compact('var1'))
https://www.youtube.com/watch?v=4RQX3nLBx8E&index=9&list=PLVSNL1PHDWvR3PeLXz6nvBkDhv1IQk4wP
Detalhes em:
https://laravel.com/docs/5.4/blade
@section('title', '| Criar novo Post');
Criar select vindo do banco:
<select id="role" class="form-control" name="role" required>
@foreach($roles as $id => $role)
<option value="{{$id}}">{{$role}}</option>
@endforeach
</select>
@extends('layouts.app') <!-- importa o arquivo app.blade.php da pasta layouts -->
@section('sidebar')
This is the master sidebar.
@show
@for ($i = 0; $i < 10; $i++)
The current value is {{ $i }}
@endfor
@foreach ($users as $user)
@if ($user->type == 1)
@continue
@endif
<li>{{ $user->name }}</li>
@if ($user->number == 5)
@break
@endif
@endforeach
@forelse ($users as $user)
<li>{{ $user->name }}</li>
@empty
<p>No users</p>
@endforelse
@while (true)
<p>I'm looping forever.</p>
@endwhile
@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($records)
// $records is defined and is not null...
@endisset
@empty($records)
// $records is "empty"...
@endempty
@can('update', $post)
@endcan
@role('admin') // @if(Auth::check() && Auth::user()->is('admin'))
// user is admin
@endrole
@permission('edit.articles') // @if(Auth::check() && Auth::user()->can('edit.articles'))
// user can edit articles
@endpermission
@allowed('edit', $article) // @if(Auth::check() && Auth::user()->allowed('edit', $article))
// show edit button
@endallowed
@role('admin|moderator', 'all') // @if(Auth::check() && Auth::user()->is('admin|moderator', 'all'))
// user is admin and also moderator
@else
// something else
@endrole
Forms
Value guardar o valor digitado
<input type="text" name="username" value="{{ old('username') }}">
Comments fornecido por CComment