Skip to main content
Category:

Blade Directives: IncludeIf, IncludeWhen, IncludeFirst


If you are not sure whether your Blade partial file actually would exist, you may use these condition commands:

This will load header only if Blade file exists

@includeIf('partials.header')

 

This will load header only for user with role_id 1

@includeWhen(auth()->user()->role_id == 1, 'partials.header')

 

This will try to load adminlte.header, if missing - will load default.header

@includeFirst('adminlte.header', 'default.header')

Riadh Rahmi

Senior Web Developer PHP/Drupal & Laravel

I am a senior web developer, I have experience in planning and developing large scale dynamic web solutions especially in Drupal & Laravel.

Web Posts

Search

Page Facebook