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
You can do it in few different ways.
Sample-1:
@if( !empty($data['var'])) {{ $data['var'] }} @endif
Sample-2:
{{ $data['var'] or 'no data found' }}
Sample-3: Using ternary operator