如果用户访问不存在的帖子的管理页面(如“ https://proj.test/post/manage/34
”),为什么会出现:
Undefined property: Illuminate\Http\RedirectResponse::$admin_id
?
错误在于AuthServiceProvider
的引导方法中:
public function boot(GateContract $gate)
{
$this->registerPolicies();
$gate->define('access-management-area', function($user, $post)
{
return $user->id == $post->admin_id;
});
}