Gate::resource 踩坑的注意
Gate::resource('posts', 'PostPolicy', [
'image' => 'updateImage',
'photo' => 'updatePhoto',
]);
并不是广义上理解的在资源方法之外新增加绑定两个Gate方法,而是替换成只有这两个方法绑定,别的资源方法都实际上都没绑定,导致view、create、update、delete失效。
如果要新增方法:
Gate::resource('posts', 'PostPolicy', [
'view' => 'view',
'create' => 'create',
'update' => 'update',
'delete' => 'delete',
'image' => 'updateImage',
'photo' => 'updatePhoto',
]);