switch case in laravel
In this session switch case in laravel, we will discuss how to use switch case in Laravel. In Laravel 5.5 and above versions @Switch is built into the Blade. So it can be used just like in plain PHP.
@switch($login_error) @case(1) `E-mail` input is empty! @break @case(2) `Password` input is empty! @break @default Something went wrong, please try again @endswitch
If you are using other versions of Laravel you can use plain PHP. You can use plain PHP in Blade. Another option switch case in laravel is to use if else approach.
@if ($login_error == 1) `E-mail` input is empty! @elseif ($login_error == 2) `Password` input is empty! @endif
Also You can learn more way about switch case in laravel