Laravel Blade Switch Case Statement Example

About Us:

We are from free coder. We are a group of web developers who are passionate about web development. You can learn from us php, laravel, node js, vue js, react js and many other topic on web developement.
we are very happy to help you.
free coder

Today what you are going to learn:

Hello Dev,

This simple article demonstrates of laravel blade switch case lesson. you will learn laravel switch case in blade. you can see switch case in laravel blade. you can understand a concept of laravel switch case lesson. Alright, let’s dive into the steps.

simple lesson of switch case statement in laravel 6, laravel 7 and laravel 8.

let's see bellow simple lesson:

Blade File Code:

<!DOCTYPE html>

<html>

<head>

<title></title>

</head>

<body>

@switch($status)

@case(1)

Active

@break

@case(2)

Wait

@break

@default

InActive

@endswitch

</body>

</html>

Controller File Code:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class AjaxController extends Controller

{

/**

* Create a new controller instance.

*

* @return void

*/

public function index()

{

$status = 2;

return view('ajaxRequest', compact('status'));

}

}

Result:-

Wait

thank you very much for following up with me.

Tags

Recent Posts

Related Posts