@petervandijck This was good. You can do one step ahead to make Custom Blade Directives Service Provider. and move this code into that file. and in config/app.php you have to include and use it regular blade directive.
return [
// ...
'providers' => [
// Other service providers...
App\Providers\CustomBladeDirectivesServiceProvider::class,
],
// ...
];