Laravel @includeIf Directive

If there is no view to call, we get an error. If we want to call view by controlling, we can use this directive. Normally we can use it like this without directive.

@if(view()->exists('view-name'))
    @include('view-name')
@endif

However, Blade gives us a directive called @includeIf. That's exactly what works and you're writing cleaner code.

@includeIf('view-name')

 

Comments

There are no comments, make the firs comment