Esempio n. 1
0
 /**
  * Updates an existent user
  *
  * @param $user
  * @param array $input
  * @return bool
  */
 public function update($user, array $input)
 {
     if (!$this->valid($input, 'updating')) {
         return false;
     }
     return $this->user->update($user, $input);
 }
Esempio n. 2
0
 public function update($slug, array $input)
 {
     $snippet = $this->snippet->bySlug($slug, $all = true);
     if (!$snippet->isTheAuthor(Auth::user())) {
         return App::abort(404);
     }
     if (!$this->valid($input)) {
         return false;
     }
     // validate if tags chosen are valid
     // @TODO: move this into a helper so we can re-use this one
     $tagIds = $this->tag->all()->lists('id');
     if (isset($input['tags']) && count($input['tags']) > 0) {
         foreach ($input['tags'] as $id) {
             if (!in_array($id, $tagIds)) {
                 return App::abort(404);
             }
         }
     }
     if (!$this->snippet->update($snippet, $input)) {
         return false;
     }
     return $snippet;
 }