public function update(array $data, $id)
 {
     try {
         $this->validator->with($data)->passesOrFail();
         return $this->repositoy->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 ['error' => true, 'message' => $e->getMessageBag()];
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => 'Project Note não encontrado'];
     }
 }
 public function update(array $data, $projectId, $noteId)
 {
     try {
         $data['project_id'] = $projectId;
         $this->validator->with($data)->passesOrFail();
         return $this->repository->update($data, $noteId);
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag()];
     } catch (\Exception $e) {
         return ["error" => true, "message" => $e->getMessage()];
     }
 }
예제 #4
0
 public function update(array $data, $project_id, $note_id)
 {
     try {
         $data['project_id'] = $project_id;
         $this->validator->with($data)->passesOrFail();
         return $this->repository->update($data, $note_id);
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag()];
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => 'A nota que está tentando atualizar não existe'];
     }
 }
예제 #5
0
 /**
  * @param array $data
  * @param $id
  * @return mixed
  */
 public function update(array $data, $id, $noteId)
 {
     try {
         $data['project_id'] = $id;
         $this->validator->with($data)->passesOrFail();
         return $this->repository->update($data, $noteId);
     } 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 = "Nota {$id} atualizada 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
 }
예제 #7
0
 public function update(array $data, $note_id)
 {
     $note = ProjectNote::find($note_id);
     if (is_null($note)) {
         return Errors::invalidId($note_id);
     }
     try {
         $this->validator->with($data)->passesOrFail();
         if ($data['project_id'] != $note->project_id) {
             return Errors::basic('Você não pode alterar o projeto da nota.');
         }
         $user_id = \Authorizer::getResourceOwnerId();
         if (!$this->projectRepository->isMember($note->project_id, $user_id)) {
             return Errors::basic('Acesso negado. Você não é membro do projeto selecionado.');
         }
         return $this->repository->update($data, $note_id);
     } catch (ValidatorException $e) {
         return Errors::basic($e->getMessageBag());
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id, $noteId)
 {
     return $this->repository->update($request->all(), $noteId);
 }
 public function update(array $data, $id)
 {
     return $this->repository->update($data, $id);
 }