laravel inline if code example
Example 1: laravel inline if
{{ $var == "hello" ? "Hi" : "Goodbye" }}
Example 2: write if and else in one line laravel
//in blade:
{{ ($data->position == 1) ? 'active' : 'disable'}}
//in Controller
$result = ($data->status == 1) ? 'active' : 'disable'
Example 3: laravel inline if else if
{{$var == 'hello' ? 'Hi' : ($var == 'bye' ? 'Goodbye' : 'another option')}}