Example #1
0
 /**
  * Show the editing page
  *
  * @param integer $id User ID
  */
 public function edit($id)
 {
     try {
         $user = User::with('role', 'soldiers.player')->findOrFail($id);
         $roles = Role::lists('role_name', 'role_id');
         $page_title = Lang::get('navigation.admin.adkats.items.users.items.edit.title', ['id' => $id]);
         Former::populate($user);
         return View::make('admin.adkats.users.edit', compact('user', 'page_title', 'roles'));
     } catch (ModelNotFoundException $e) {
         return Redirect::route('admin.adkats.users.index')->withErrors([sprintf('User #%u doesn\'t exist.', $id)]);
     }
 }
Example #2
0
 public function store()
 {
     try {
         $role = new Role();
         $permissions = new Collection(Input::get('permissions', []));
         if (Input::has('permissions')) {
             $permissions = $permissions->filter(function ($id) {
                 if (is_numeric($id)) {
                     return true;
                 }
             })->map(function ($id) {
                 return (int) $id;
             });
         }
         $v = Validator::make(Input::all(), ['role_name' => 'required']);
         if ($v->fails()) {
             return Redirect::route('admin.adkats.roles.create')->withErrors($v)->withInput();
         }
         $role->role_name = Input::get('role_name');
         $role->save();
         // Update role permissions
         $role->permissions()->sync($permissions->toArray());
         return Redirect::route('admin.adkats.roles.edit', $role->role_id)->withMessages(['Role Created!']);
     } catch (ModelNotFoundException $e) {
         return Redirect::route('admin.adkats.roles.index');
     }
 }