So instead of using the commonly "include" blade directive like below.
@include('partials.announcement', ['status' => 'complete'])
You can instead make use of "includeIf" directive and when the "announcement" partials exist, they will be imported to the views, otherwise, no partials will be loaded.
@includeIf('partials.announcement', ['status' => 'complete'])
In the case that you want to include the views only on truthy condition then make use of "includeWhen" and specify the boolean condition.
@includeWhen($boolean, 'view.name', ['status' => 'complete'])
Otherwise, you can define the inverse condition and define it using "includeUnless" like below.
@includeUnless($boolean, 'view.name', ['status' => 'complete'])
Leave a reply