/** * @return void * @throws ManagerValidationException */ public function update() { if (is_null($this->entity)) { throw new \Exception('InvalidNotFoundUser'); } $id = $this->entity->id; $validation = \Validator::make($this->data, $this->rules); if ($validation->fails()) { $users = User::where('email', $this->data['email'])->orWhere('username', $this->data['username'])->get(); if (count($users) != 1) { throw new ManagerValidationException('Validation failed', $validation->messages()); } } if (isset($this->data['category_id'])) { $this->entity->category_id = $this->data['category_id']; } $this->entity->update($this->prepareData($this->data)); }