Laravel 5.1 @can, how use OR clause

后端 未结 8 1346
日久生厌
日久生厌 2021-02-06 22:40

I did not find how to use a clause (OR, AND) in view with @can, for checking multiple abilities ...

I tried:

@can([\'permission1\', \'permission2\']) 
@c         


        
相关标签:
8条回答
  • 2021-02-06 23:30

    If you are using laravel spatie package , then you can do it easily by following way..

    Using hasAnyPermission() method

    @if(auth()->user()->hasAnyPermission(['permission1','permission2']))
       // statements 
    @endif
    
    
    0 讨论(0)
  • 2021-02-06 23:33

    You can call @can multiple times.

    @if( @can('permission1') || @can('permission2') )

    @if( Gate::check('permission1') || Gate::check('permission2') )
    
    0 讨论(0)
提交回复
热议问题