阅读(1137) (4)

Laravel 8 不依赖模型的动作

2021-06-29 16:33:54 更新

与大多数其他授权方法一样,如果动作不需要模型实例,则可以将类名传递给 @can@cannot 指令:

@can('create', AppModels::class)
    <!-- 当前用户可以更新文章 -->
@endcan

@cannot('create', AppModels::class)
    <!-- 当前用户不可以更新文章 -->
@endcannot