/** * Update the specified resource in storage. * PUT /roles/{id} * * @param int $id * @return Response */ public function update($id) { $role = \Role::findOrFail($id); $role->update(\Input::all()); $role->assignPermissions(\Input::get('permissions')); return \Redirect::route('admin.roles.index'); }
/** * Update the specified role in storage. * * @param int $id * @return Response */ public function update($id) { $role = Role::findOrFail($id); $validator = Validator::make($data = Input::all(), Role::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $role->update($data); return Redirect::route('roles.index'); }
/** * Update the specified resource in storage. * PUT /roles/{id} * * @param int $id * @return Response */ public function update($id) { $role = Role::findOrFail($id); if ($role) { $perms = Input::get('perms'); $permsToAttach = []; if (Input::has('perms')) { foreach ($perms as $key => $value) { $perm = Permission::where('id', '=', $key)->first(); if ($perm) { array_push($permsToAttach, $perm->id); } } } $role->perms()->sync($permsToAttach); if (Input::has('display_name')) { $role->display_name = Input::get('display_name'); } $role->save(); return Redirect::to('admin/roles')->with(['roles-notice' => 'Role has been updated']); } return Redirect::to('admin/roles')->with(['roles-notice' => 'Error updating role']); }
public static function moderator() { return Role::findOrFail(32); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $role = $this->role->findOrFail($id); return View::make('roles.show', compact('role')); }
/** * Remove the specified role from storage. * * @param int $id * @return Response */ public function destroy($id) { $role = Role::findOrFail($id); if (!$role->canDelete()) { return $this->_access_denied(); } if (!$role->delete()) { return $this->_delete_error(); } if (Request::ajax()) { return Response::json($this->deleted_message); } return Redirect::route('roles.index')->with('notification:success', $this->deleted_message); }
public function edit() { $role = Role::findOrFail(Input::get('role_id')); $permissions = $role->perms()->get(); return View::make('roles.edit', compact('role', 'permissions')); }
/** * Display the specified role. * * @param int $id * @return Response */ public function show($id) { $role = Role::findOrFail($id); $this->layout->title = 'Add Role'; $this->layout->content = View::make('roles.show', compact('role')); }