In this post on his Medium blog INANI El Houssain shows you how to create a custom directive for use with Laravel's Blade templating language. In this example he shows how to make a custom switch statement, something commonly used on the PHP side to select an action based on a value.
One of the good points of Laravel’s framework is that it allows you to make your own components, macros and directives. so today we will make use of Laravel’s Custom Blade directives and make something good.
He starts with a simple "hello world" example to show where the pieces all live, outputting a simple "Hello $name" string. He then moves into the creation of the "@switch" directive having it write out the PHP code required for the switch to start and end. He adds in two more tags to start and end the different cases: @case and @endcase. The post wraps up with an example of all of these tags in use and how to catch when the value under evaluation might be empty.