public function edit()
 {
     $data = Input::all();
     // If no icon given
     if ($this->isEmpty($data['edit']['icon'])) {
         return $this->jsonResponse(400, false, "The icon field cannot be left empty!");
     }
     // If invalid font awesome name
     if (!$this->isValidFontAwesome($data['edit']['icon'])) {
         return $this->jsonResponse(400, false, "The icon name supplied is not a valid Font Awesome icon!");
     }
     // Page must have a role attached
     if (count($data['edit']['role']) == 0) {
         return $this->jsonResponse(400, false, "A page must have at least one role!");
     }
     try {
         $page = $this->pages->edit($data['id'], ['icon' => $data['edit']['icon']]);
         $roles = $this->roles->getAll();
         foreach ($roles as $role) {
             $this->pages->removeRole($page, $role['id']);
         }
         //Give page new set of chosen roles
         foreach ($data['edit']['role'] as $role) {
             $this->pages->assignRole($page, $role['id']);
         }
     } catch (Exception $e) {
         return $this->jsonResponse(400, false, $e->getMessage());
     }
     return $this->jsonResponse(200, true, 'Page successfully updated!', $this->pages->getWithRoles($data['id']));
 }
 /**
  * Validates an incoming response from Steam against the database
  *
  * @return Redirect
  */
 public function validateSteamLogin()
 {
     $validate = SteamLogin::validate();
     if (is_null($validate)) {
         throw new Exception(Lang::get('auth.invalidResponse'));
     } else {
         $steamObject = new SteamId($validate);
         if ($this->users->count() == 0) {
             $user = $this->users->add($this->userDetails($steamObject));
             $roles = $this->roles->getAll();
             foreach ($roles as $role) {
                 $this->users->assignRole($user, $role->id);
             }
             Auth::login($user);
             return Redirect::route('settings')->withFlashNotification(Lang::get('auth.firstLogin'))->withFlashNotificationLevel('success');
         } else {
             $user = $this->users->getFirst('community_id', $steamObject->getSteamId64());
             if (is_null($user)) {
                 throw new Exception(Lang::get('auth.noAccess'));
             } else {
                 if ($user->enabled == 0) {
                     throw new Exception(Lang::get('auth.accountDisabled'));
                 } else {
                     $this->users->edit($user->id, $this->userDetails($steamObject));
                     Auth::login($user);
                     return Redirect::route('dashboard')->withFlashNotification(Lang::get('auth.successfulLogin'))->withFlashNotificationLevel('success');
                 }
             }
         }
     }
 }