Laravel @includeFirst Directive

We use this directive to check if a view exists and to load another view if it does not exist, alternatively. Without a directive, we normally need to use it like this.

@if(view()->exists('first-view'))
    @include('first-view')
@else
    @include('two-view')
@endif

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

@includeFirst(['first-view', 'two-view']);
Comments

There are no comments, make the firs comment