Laravel Blade Switch Case Example

In this example we will show laravel blade switch case example. I explain simple demonstrates of laravel blade switch case example. In this post you learn laravel blade switch case example. you will learn laravel switch case in blade.

Switch statements can be constructed using the @switch, @case, @break, @default and @endswitch directives. Simple example of switch case statement in laravel 6, laravel 7 and laravel 8.

Syntax

@switch($i)
    @case(1)
        First case...
        @break

    @case(2)
        Second case...
        @break

    @default
        Default case...
@endswitch

Example

<!DOCTYPE html>
<html>
<head>
    <title>Laravel Blade Switch Case Example - web-tuts.com</title>
</head>
<body>
    @switch($i)
        @case(1)
            First case...
            @break

        @case(2)
            Second case...
            @break

        @default
            Default case...
    @endswitch
</body>
</html>

I hope you understand of laravel blade switch case example and it can help you…