Ejemplo n.º 1
0
 /**
  * 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');
 }
Ejemplo n.º 2
0
 /**
  * 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');
 }
Ejemplo n.º 3
0
 /**
  * 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']);
 }
Ejemplo n.º 4
0
 public static function moderator()
 {
     return Role::findOrFail(32);
 }
Ejemplo n.º 5
0
 /**
  * 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'));
 }
Ejemplo n.º 6
0
 /**
  * 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);
 }
Ejemplo n.º 7
0
 public function edit()
 {
     $role = Role::findOrFail(Input::get('role_id'));
     $permissions = $role->perms()->get();
     return View::make('roles.edit', compact('role', 'permissions'));
 }
Ejemplo n.º 8
0
 /**
  * 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'));
 }