Check if variable exist in laravel's blade directive

前端 未结 13 1440
清歌不尽
清歌不尽 2021-02-03 19:23

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

13条回答
  •  野性不改
    2021-02-03 19:31

    You can use in Blade functionality for checking isset i.e

    {{ $checkvariable or 'not-exist' }}
    

    https://laravel.com/docs/5.2/blade#displaying-data

提交回复
热议问题