public function update(array $data, $id)
 {
     try {
         $this->validator->with($data)->passesOrFail();
         return $this->repository->update($data, $id);
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag()];
     }
 }
 public function update(array $data, $id)
 {
     try {
         $this->validator->with($data)->passesOrFail();
         return $this->repository->update($data, $id);
     } catch (ValidatorException $e) {
         return response()->json(['error' => true, 'message' => $e->getMessageBag()]);
     } catch (ModelNotFoundException $e) {
         return response()->json(['error' => true, 'message' => "Project id {$id} not found"]);
     }
 }
 public function update(array $data)
 {
     try {
         $this->validator->with($data)->passesOrFail();
         return $this->repository->create($data);
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag()];
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => 'Não foi possível atualizar as informações do projeto. Projeto não encontrado.'];
     }
 }
 public function update(array $data, $id)
 {
     try {
         $this->validator->with($data)->passesOrFail();
         $P = $this->repository->find($id)->update($data);
         if ($P) {
             // return "O projeto '".$data['name']."', foi editado com sucesso!";
             return ['error' => false, 'message' => "O projeto '" . $data['name'] . "', foi editado com sucesso!"];
         }
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag()];
     }
 }
 public function update(array $data, $id)
 {
     try {
         $this->validator->with($data)->passesOrFail(ValidatorInterface::RULE_UPDATE);
         return $this->repository->setPresenter($this->presenter)->update($data, $id);
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag(), "messageDev" => 'ValidatorException'];
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => 'Registro não encontrado.', "messageDev" => $e->getMessage()];
     } catch (\Exception $e) {
         return ["error" => true, "message" => 'Falha ao atualizar dados.', "messageDev" => $e->getMessage()];
     }
 }
Beispiel #6
0
 /**
  * @param array $data
  * @param $id
  * @return mixed
  */
 public function update(array $data, $id)
 {
     try {
         $this->validator->with($data)->passesOrFail();
         return $this->repository->update($data, $id);
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag()];
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => 'No data found'];
     } catch (\Exception $e) {
         return ['error' => true, 'message' => 'An error occurred when trying to update the data. Try again later.'];
     }
 }
 /**
  * @param array $data
  * @param $id
  * @return \Illuminate\Http\JsonResponse
  */
 public function update(array $data, $id)
 {
     try {
         $this->validator->with($data)->setId($id)->passesOrFail(ValidatorInterface::RULE_UPDATE);
         $update = $this->repository->update($data, $id);
         $msg = "Projeto {$id} atualizado com sucesso.";
         Log::info($msg);
         return response()->json(["message" => $msg, "data" => $update->toArray()], 200);
     } catch (ValidatorException $e) {
         return response()->json([$e->getMessageBag()], 400);
     } catch (ModelNotFoundException $e) {
         return response()->json([$e->getMessage()], 404);
     }
     //QueryException tratado em Exceptions/Handler.php
 }
 public function update(array $data, $id)
 {
     $project = Project::find($id);
     if (is_null($project)) {
         return Errors::invalidId($id);
     }
     try {
         $this->validator->with($data)->passesOrFail();
         if ($data['owner_id'] != $project->owner_id) {
             return Errors::basic('O dono do projeto nao pode ser alterado!');
         }
         return $this->repository->update($data, $id);
     } catch (ValidatorException $e) {
         return Errors::basic($e->getMessageBag());
     }
 }