condition in blade laravel code example
Example 1: laravel if syntax
@if (foo)
// do something
@elseif (bar)
// do something else
@else
// do some other thing;
@endif
Example 2: use if in laravel blade
@if($user->status =='active')
<td>{{ $user->name }}</td>
@else
<td> Guest </td>
@endif
Example 3: laravel when condition
$invisiblePosts = $request->query('invisible');
Article::query()
->when($invisiblePosts , function ($query){
return $query->where('invisible' , true);
},function ($query){
return $query->where('invisible' , false);
})
->get();