/** * Adds the specified permission onto the requested roles. * * @param PermissionRoleRequest $request * @param int|string $permissionId * * @return array|false */ public function store(PermissionRoleRequest $request, $permissionId) { $this->authorize('admin.roles.permissions.store'); $permission = $this->permission->findOrFail($permissionId); $roles = $request->input('roles', []); if (count($roles) > 0) { $roles = $this->role->findMany($roles); return $permission->roles()->saveMany($roles); } return false; }
/** * Adds the specified permission to the requested roles. * * @param PermissionRoleRequest $request * @param int|string $permissionId * * @return \Illuminate\Http\RedirectResponse */ public function store(PermissionRoleRequest $request, $permissionId) { $this->authorize('admin.roles.permissions.store'); $permission = $this->permission->findOrFail($permissionId); $roles = $request->input('roles', []); if (count($roles) > 0) { $roles = $this->role->findMany($roles); $permission->roles()->saveMany($roles); flash()->success('Success!', 'Successfully added roles.'); return redirect()->route('admin.permissions.show', [$permissionId]); } flash()->error('Error!', "You didn't select any roles!"); return redirect()->route('admin.permissions.show', [$permissionId]); }