i使用jenssegers-mongodb和laravel-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');
}
对不起,英语不好:(