Blade Template Tutorial Two Including Subviews in Laravel 11

 <a href="{{ route('bladeTempla') }}">Blade Template Page</a>

@php
$fruits = ["Apple", "Banana", "Orange", "Grapes"];
@endphp

{{-- @include("pages.header", ["names" => $fruits]) --}}
{{-- @include("pages.header", ["name" => "Hello World"]) --}}
<h1>Home Page</h1>
@include("pages.footer")

@php
$vehicles = ["one" => "car", "two" => "cycle", "three" => "Motorcycle", "four" => "Aeroplane", "five" => "scooter"];
$value = "";
@endphp
@include("pages.header", ["vehicleNames" => $vehicles])

{{-- Checking whether view File is present OR Not and if Present then only output will appear otherwise No any error will appear --}}
@includeIf("pages.content")

@includeWhen(true, "pages.header", ["vehicleNames" => $vehicles])
@includeWhen(empty($value), "pages.header", ["vehicleNames" => $vehicles])
@includeUnless(empty($value), "pages.header", ["vehicleNames" => $vehicles])





Below File is header.blade.php File
<h1>Header Page</h1>
{{-- <p>{{ $name }}</p> --}}

{{-- @foreach($names as $n)
<p>{{ $n }}</p>
@endforeach --}}

@foreach($vehicleNames as $key => $value)
<p>{{ $key }} : {{ $value }}</p>
@endforeach

@forelse($vehicleNames as $key => $value)
    <p>{{ $key }} - {{ $value }}</p>
@empty
    <p>No Value Found.</p>
@endforelse





Comments

Popular posts from this blog

Eloquent Many to Many Relationship Tutorial in Laravel 11

Eloquent with JSON Data Columns Tutorial in Laravel 11

Blade Template Tutorial Three Template Inheritance in Laravel 11