I\'m trying to create blade directive which echo variable (if variable defined) or echo \"no data\" if variable undefined.
This is my code in AppServiceProvider.ph
AppServiceProvider.ph
What are you trying to pass to your custom directive? If it's just a string/int the following should work.
Blade::directive('p', function($expression){ $output = $expression ? $expression : 'nodata'; return ""; });
In Blade Template
@p('Foo')