请问一个 authorize的问题
各位学长好,后学在此请教一问题,代码如下:
/**
* show
* 显示作业
*/
public function show(StudentWork $studentWork){
$this->authorize('show',$studentWork);
return new StudentWorkResource($studentWork);
}
调用后,报 403:
这个 studentWork = 1 是这个用户的.
如果不写 $this->authorize (‘show’,$studentWork);
是能正常返回的。
在 StudentWorkPolicy.php 文件中,代码是:
class StudentWorkPolicy extends Policy
{
public function show(User $user, StudentWork $studentWork)
{ return $user->isAuthorOf($studentWork);
}
}
我对比了课程中的内容,不知问题在哪里,请问哪位学长能指点吗?
非常感谢!
本作品采用《CC 协议》,转载必须注明作者和本文链接
推荐文章: