{{-- everything.blade.php: a deliberately messy, exhaustive Blade document --}} @php use App\Models\User; use App\Support\Money; @endphp @use('App\Enums\Status') @inject('metrics', 'App\Services\Metrics') @yield('title', 'Dashboard') ยท {{config('app.name')}} @stack('head') {{-- top navigation --}}
{{-- flash + validation errors --}} @if(session('status'))
{{session('status')}}
@elseif(session('warning'))
{{session('warning')}}
@endif @error('email')

{{$message}}

@enderror @error('password')

{{$message}}

@else

Choose a strong password.

@enderror @if($errors->any()) @endif {{-- switch over a status enum --}} @switch($status) @case(Status::Active) Active @break @case(Status::Pending) @case(Status::Review) Waiting @break @case(Status::Archived) Archived @break @default Unknown @endswitch {{-- nested loops with forelse + loop variable --}} @foreach($groups as $group) @continue($group->hidden)
$loop->first])>

{{$loop->iteration}}. {{$group->name}}

@forelse($group->items as $item)
$loop->first,'item--last'=>$loop->last]) wire:key="item-{{$item->id}}">

{{$item->title}}

@isset($item->author)

By {{$item->author->name}}

@endisset @unless($item->published) Draft @endunless

{{Str::limit($item->body,120)}}

{!! $item->rendered_html !!} Price: {{Money::format($item->price)}} @if($item->onSale) {{$item->price}} {{$item->sale_price}} @elseif($item->preorder) Pre-order @else {{$item->price}} @endif @if($item->tags->isNotEmpty())
    @foreach($item->tags as $tag)
  • $tag->primary])>{{$tag->name}}
  • @endforeach
@endif
@empty

Nothing here yet.

@endforelse
@endforeach {{-- while loop with break/continue --}} @php $i=0; @endphp @while($i<$limit) @php $i++; @endphp @continue($i%2===0) @if($i>100) @break @endif {{$i}} @endwhile {{-- classic for loop --}} @for($page=1;$page<=$pages;$page++) $page===$current])>{{$page}} @endfor {{-- components, slots, attributes --}}

{{$heading}}

@foreach($links as $link) {{$link['label']}} @endforeach Default slot content goes right here. {{$card->title}} {{$card->body}} {{-- deeply nested conditionals inside components --}} @if($user->subscribed()) @if($user->onTrial()) Trial @else @if($user->onGracePeriod()) Grace period @else Active @endif @endif @else Free @endif {{-- forms with attribute directives --}}
@csrf @method('PUT') $errors->has('email')])>
{{-- tables --}} @forelse($users as $user) $loop->odd,'even'=>$loop->even,'row--you'=>$user->is(auth()->user())])> @empty @endforelse
NameEmailStatusJoined
{{$user->name}} {{$user->email}} @if($user->active) โœ“ @else โœ— @endif {{$user->created_at->diffForHumans()}} @can('update',$user) Edit @endcan
No users found.
Total: {{$users->total()}}
{{$users->links()}} {{-- a grid of cards built from a collection --}}
@foreach($products as $product) $product->featured])> {{$product->name}}

{{$product->name}}

{{$product->description}}

@if($product->inStock()) @else Out of stock @endif
@endforeach
{{-- alpine tabs --}}
{{$overview}}
@foreach($activities as $activity)

{{$activity->actor}} {{$activity->description}}

@endforeach
{{$settingsPanel}}
{{-- a modal built with alpine --}}
{{-- includes and each --}} @include('partials.footer',['year'=>date('Y')]) @includeIf('partials.debug') @includeWhen($debug,'partials.debug-panel',['data'=>$debugData]) @includeUnless($production,'partials.dev-banner') @includeFirst(['custom.hero','default.hero']) @each('partials.comment',$comments,'comment','partials.no-comments') {{-- push, prepend, once --}} @push('scripts') @endpush @pushOnce('styles') @endPushOnce @prepend('scripts') @endprepend @once @endonce {{-- verbatim + escaped echoes --}} @verbatim
{{ vueVariable }} and @{{ alsoVue }}
@endverbatim

Literal braces: @{{ notBlade }}

{{-- fragments (Livewire) --}} @fragment('list') @endfragment {{-- long echo that should wrap --}}
{{$user->subscription->active?'Subscribed and enjoying every single premium feature we offer to our valued customers':'Not subscribed to any plan at the moment, so please consider upgrading today'}}
{{-- chained method echo --}}

{{collect($metrics->all())->map(fn($m)=>$m->value)->filter(fn($v)=>$v>0)->sum()}}

{{-- raw echo and escaped braces mixed --}}
{!! $trustedHtml !!}
{{-- definition list --}}
@foreach($facts as $term=>$definition)
{{$term}}
{{$definition}}
@endforeach
{{-- blockquote with nested echo --}}

{{$quote->text}}

โ€” {{$quote->author}}
{{-- alpine + inline handlers --}}
{{-- svg icons --}} {{-- environment + auth gates --}} @production @endproduction @env(['local','staging'])
{{app()->environment()}}
@endenv @hasSection('banner') @endif @sectionMissing('banner') @endif @can('update',$post) Edit @elsecan('view',$post) View @cannot('delete',$post) Cannot delete @endcan {{-- lang + choice --}}

@lang('messages.welcome',['name'=>$user->name])

{{trans_choice('messages.items',$count,['count'=>$count])}}

{{-- session directive --}} @session('success')
{{$value}}
@endsession {{-- json into a script --}} {{-- a raw pre block that must be preserved --}}
function greet(name) {
    return "Hello, " + name;
}
{{-- a nested @php block computing a summary --}} @php $summary = [ 'total' => $total, 'active' => $activeCount, 'ratio' => $total > 0 ? round($activeCount / $total, 2) : 0, ]; @endphp {{-- notifications dropdown with nested loops --}}
{{-- an FAQ accordion --}}

Frequently asked questions

@foreach($faqs as $index=>$faq)

{{$faq['answer']}}

@isset($faq['link']) Learn more @endisset
@endforeach
{{-- a pricing table with nested loops --}}
@foreach($plans as $plan)
$plan->popular])>

{{$plan->name}}

{{Money::format($plan->price)}}/{{$plan->interval}}

    @foreach($plan->features as $feature)
  • $feature->included])> @if($feature->included) โœ“ @else โœ— @endif {{$feature->label}}
  • @endforeach
@csrf
@endforeach
{{-- a threaded comments list --}}

{{trans_choice('comments.count',$comments->count(),['count'=>$comments->count()])}}

@forelse($comments as $comment)
{{$comment->author->name}} {{$comment->author->name}} @if($comment->author->is($post->author)) Author @endif
{!! $comment->rendered_body !!}
@can('reply',$comment) @endcan @if($comment->replies->isNotEmpty())
@foreach($comment->replies as $reply)
{{$reply->author->name}}
{{$reply->body}}
@endforeach
@endif
@empty

Be the first to comment.

@endforelse
{{-- a settings form with fieldsets --}}
@csrf @method('PATCH')
Profile @foreach($profileFields as $field)
@error($field['name'])

{{$message}}

@enderror
@endforeach
Preferences @foreach($preferences as $preference) @endforeach
Notifications
{{-- a stats dashboard driven by @foreach + @switch --}}
@foreach($widgets as $widget)
size]) wire:key="widget-{{$widget->id}}">

{{$widget->title}}

@switch($widget->type) @case('metric')

{{$widget->formattedValue}}

@if($widget->trend>0) โ–ฒ {{$widget->trend}}% @elseif($widget->trend<0) โ–ผ {{abs($widget->trend)}}% @else โ€” @endif @break @case('list')
    @foreach($widget->rows as $row)
  • {{$row->label}}: {{$row->value}}
  • @endforeach
@break @case('chart')
@break @default

Unsupported widget.

@endswitch
@endforeach
{{-- a timeline --}}
    @foreach($events as $event)
  1. $event->milestone])>

    {{$event->summary}}

    @unless($event->attachments->isEmpty()) @endunless
  2. @endforeach
{{-- a kanban board with nested columns and cards --}}
@foreach($columns as $column)
$column->cards->isEmpty()])>

{{$column->name}}

{{$column->cards->count()}}
@forelse($column->cards as $card)

{{$card->title}}

@if($card->assignee) {{$card->assignee->name}} @endif @if($card->labels->isNotEmpty())
    @foreach($card->labels as $label)
  • {{$label->name}}
  • @endforeach
@endif
@if($card->due_at?->isPast()) Overdue @endif
@empty

Drop cards here.

@endforelse
@endforeach
{{-- a multi-step wizard driven by a for loop --}}
    @for($step=1;$step<=count($steps);$step++)
  1. $step<$current,'step--current'=>$step===$current])> {{$step}} {{$steps[$step-1]['label']}}
  2. @endfor
@foreach($steps as $index=>$step)

{{$step['heading']}}

@foreach($step['fields'] as $field)
@endforeach
@endforeach
{{-- a media gallery --}} {{-- a filters sidebar --}} {{-- a mega footer with columns --}} {{-- a calendar grid built from nested loops --}} @foreach($weekdays as $weekday) @endforeach @foreach($weeks as $week) @foreach($week as $day) @endforeach @endforeach
{{$month->format('F Y')}}
{{$weekday['short']}}
$day['isToday'],'day--outside'=>!$day['inMonth'],'day--busy'=>count($day['events'])>0])> {{$day['number']}} @if(count($day['events'])>0)
    @foreach($day['events'] as $event)
  • $event['allDay']]) title="{{$event['title']}}"> @unless($event['allDay']) @endunless {{Str::limit($event['title'],18)}}
  • @endforeach
@endif
{{-- a chat message thread --}}
@foreach($messages as $message)
$message->user->is(auth()->user()),'message--system'=>$message->system]) wire:key="msg-{{$message->id}}"> @unless($message->system) {{$message->user->name}} @endunless
@if($message->system) {{$message->body}} @else {{$message->user->name}}

{!! nl2br(e($message->body)) !!}

@if($message->attachments->isNotEmpty()) @foreach($message->attachments as $attachment) ๐Ÿ“Ž {{$attachment->name}} @endforeach @endif @endif
@endforeach
{{-- a KPI row --}}
@foreach($kpis as $kpi)

{{$kpi['label']}}

{{$kpi['value']}}

@isset($kpi['delta'])

$kpi['delta']>=0,'kpi__delta--down'=>$kpi['delta']<0])> {{$kpi['delta']>=0?'+':''}}{{$kpi['delta']}}%

@endisset
@endforeach
{{-- breadcrumbs --}} {{-- an invoice with line items and totals --}}

Invoice #{{$invoice->number}}

Issued {{$invoice->issued_at->format('M j, Y')}}

@if($invoice->paid) Paid @elseif($invoice->overdue) Overdue @else Due {{$invoice->due_at->diffForHumans()}} @endif
@foreach($invoice->lineItems as $line) @endforeach @if($invoice->discount>0) @endif
ItemQtyUnitTotal
{{$line->description}} @isset($line->note) {{$line->note}} @endisset {{$line->quantity}} {{Money::format($line->unitPrice)}} {{Money::format($line->total)}}
Subtotal{{Money::format($invoice->subtotal)}}
Discount-{{Money::format($invoice->discount)}}
Tax ({{$invoice->taxRate}}%){{Money::format($invoice->tax)}}
Total{{Money::format($invoice->total)}}
{{-- a recursive-looking nested menu tree --}}
@section('footer') @show @stack('scripts')