Laravel - Blade Templates - Custom If Statements

Programming a custom directive is sometimes more complex than necessary when defining simple, custom conditional statements. For that reason, Blade provides a Blade::if method which allows you to quickly define custom conditional directives using closures. For example, let's define a custom conditional that checks the configured default "disk" for the application. We may do this in the boot method of our AppServiceProvider:

    use Illuminate\Support\Facades\Blade;
     * Bootstrap any application services.
     * @return void
    public function boot()
        Blade::if('disk', function ($value) {
            return config('filesystems.default') === $value;

Once the custom conditional has been defined, you can use it within your templates: