在laravel-permission mongodb和jenssegers中存储权限和角色

时间:2018-06-27 07:27:32

标签: mongodb laravel permissions

i使用jenssegers-mongodblaravel-permission-mongodb。当我尝试存储分配给角色(image is here)的权限时,存储了该权限,但具有此权限(而不是更新和权限)的角色没有分配给角色

我存储权限的代码:

public function store(Request $request)
{
    $this->validate($request, [
        'name'=>'required|max:40',
    ]);
    $permission = new Permission();
    $permission->name = $request->name;
    $permission->save();

    if ($request->roles <> '') { 
        foreach ($request->roles as $key=>$value) {
            $role = Role::find($value);
            $role->permissions()->attach($permission);
        }
    }
    return redirect()->route('permissions.index')->with('success','Permission added successfully');

}

对不起,英语不好:(

0 个答案:

没有答案