Blade is the templating engine that comes stock with a Laravel installation. It provides ways to section, display data, use control structures, and even use service injection. All Blade views are compiled into plain PHP code and cached until they are modified, meaning Blade adds essentially zero overhead to your application.

While blade comes with plenty out of the box, as you build your application you may want to extend the functionality that you see yourself repeating in multiple views.

Back in Laravel <5, it was a pain in the butt, but as of Laravel 5+, it is much simpler and provides a fluid API to do so.

The best place to register your blade extensions would be in a service provider that gets bootstrapped when your application loads. Laravel comes with AppServiceProvider out of the box, which is a good place to put your blade extensions to start. Later on you may want to move them to a more specific service provider.

You are going to want to register your extensions in the service providers register method, go figure:

Here is an example from one of my open source projects:

As you can see, we use the Blade::directive call to register a new extension, and the guts are pretty self explanatory.

In this example I am spitting out a helper function that determines whether the currently logged in user has a give role to continue whatever the application is trying to authenticate.

Since it is an if statement, you also need a blade directive to close the if statement.

Using the above example would look like so:

For more information on extending blade click here.
For more examples from my boilerplate project click here.