How to Conditionally Include a Blade Template in Laravel
In this lesson, we will see how to conditionally include a blade template in Laravel.
Sometimes, we want to include a blade template only if a condition is true, so how can we do that?
Conditionally include the blade template
To do that as the code below shows we use "@includeWhen".
The first param is the condition the second is the blade template and the third one is the data passed.
@includeWhen($showAlerts,'alerts.blade.php',['alert' => 'success']);