public function setup()
{
// take care of LIST operations
if (\Auth::user()->hasRole('admin')) {
$this->crud->addClause('where', 'author_id', '=', \Auth::user()->id);
}
}
// place this both inside your update() and inside your destroy() method
if (\Auth::user()->hasRole('admin') && $this->crud->entry->author_id!=\Auth::user()->id) {
abort(405);
}
1 回答
过滤您在实体的CrudController的
setup()
方法中显示的结果,然后禁止访问更新/销毁方法 .你的结果看起来像这样:
此外,您需要在
update()
和destroy()
方法中放置支票,以禁止管理员删除其他人的条目 .希望能帮助到你 .