{{-- Displaying Data --}}
Hello, {{ $name }}.
The current UNIX timestamp is {{ time() }}.
{{-- Escape Data --}}
Hello, {{{ $name }}}.
{{-- Echoing Data If It Exists --}}
{{ isset($name) ? $name : 'Default' }}
{{ $name or 'Default' }}
{{-- Displaying Unescaped Data --}}
Hello, {!! $name !!}.
{{-- Rendering JSON --}}
{{-- Blade & JavaScript Frameworks --}}
Hello, @{{ name }}.
{{-- Blade --}}
@@json()
@json()
@verbatim
Hello, {{ name }}.
@endverbatim
{{-- Control Structures --}}
{{-- If Statements --}}
@if (count($records) === 1)
I have one record!
@elseif (count($records) > 1)
I have multiple records!
@else
I don't have any records!
@endif
@unless (Auth::check())
You are not signed in.
@endunless
@isset($records)
// $records is defined and is not null...
@endisset
@empty($records)
// $records is "empty"...
@endempty
{{-- Authentication Directives --}}
@auth
// The user is authenticated...
@endauth
@guest
// The user is not authenticated...
@endguest
@auth('admin')
// The user is authenticated...
@endauth
@guest('admin')
// The user is not authenticated...
@endguest
{{-- Section Directives --}}
@hasSection('navigation')
@yield('navigation')
@endif
@sectionMissing('navigation')
@include('default-navigation')
@endif
{{-- Environment Directives --}}
@production
// Production specific content...
@endproduction
@env('staging')
// The application is running in "staging"...
@endenv
@env(['staging', 'production'])
// The application is running in "staging" or "production"...
@endenv
{{-- Section Directives --}}
@hasSection('navigation')
@yield('navigation')
@endif
@sectionMissing('navigation')
@include('default-navigation')
@endif
{{-- Switch Statements --}}
@switch($i)
@case(1)
First case...
@break
@case(2)
Second case...
@break
@default
Default case...
@endswitch
{{-- Loops --}}
@for ($i = 0; $i < 10; $i++)
The current value is {{ $i }}
@endfor
@foreach ($users as $user)
@break($user->number == 5)
@endforeach
{{-- The Loop Variable --}}
@foreach ($users as $user)
@if ($loop->first)
This is the first iteration.
@endif
@if ($loop->last)
This is the last iteration.
@endif
This is user {{ $user->id }}
{{-- $loop->parent --}}
@foreach ($user->posts as $post)
@if ($loop->parent->first)
This is the first iteration of the parent loop.
@endif
@endforeach
@endforeach
{{-- Loop Variables --}}
{{-- The index of the current loop iteration (starts at 0) --}}
{{ $loop->index }}
{{-- The current loop iteration (starts at 1) --}}
{{ $loop->iteration }}
{{-- The iteration remaining in the loop --}}
{{ $loop->remaining }}
{{-- The total number of items in the array being iterated --}}
{{ $loop->count }}
{{-- Whether this is the first iteration through the loop --}}
{{ $loop->first }}
{{-- Whether this is the last iteration through the loop --}}
{{ $loop->last }}
{{-- The nesting level of the current loop --}}
{{ $loop->depth }}
{{-- When in a nested loop, the parent's loop variable --}}
{{ $loop->parent }}
@endforeach
{{-- Comments --}}
{{-- This comment will not be present in the rendered HTML --}}
{{--
This comment will not be in the rendered HTML
This comment will not be in the rendered HTML
This comment will not be in the rendered HTML
--}}
{{-- PHP --}}
= $name; ?>
format('m/d/Y H:i'); ?>
@php ($hello = "hello world")
@php
foreach (range(1, 10) as $number) {
echo $number;
}
@endphp
{{-- Conditional Classes : `@class` directive --}}
@php
$isActive = false;
$hasError = true;
@endphp
$isActive,
'text-gray-500' => ! $isActive,
'bg-red' => $hasError,
])>
{{-- The @once Directive --}}
@once
@push('scripts')
@endpush
@endonce
{{-- Forms --}}
{{-- Validation Errors --}}
@error('title')