/**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id, $taskId)
 {
     try {
         return ['success' => $this->repository->delete($taskId)];
     } catch (ModelNotFoundException $e) {
         return response()->json(['Erro' => '1', 'Mensagem' => 'Registro nao localizado']);
     }
 }
 public function read($id)
 {
     try {
         return response()->json($this->repository->with(['project'])->find($id));
     } catch (ModelNotFoundException $ex) {
         return $this->notFound($id);
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     try {
         $this->repository->delete($id);
         return ['status' => 'success', 'message' => 'ProjectTask removed'];
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => 'ProjectTask not Found'];
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index($id)
 {
     if ($this->checkProjectPermissions($id) == false) {
         return ['error' => 'Access Forbidden'];
     }
     //$this->repository->with('project');
     //return $this->repository->all();
     return $this->repository->findWhere(['project_id' => $id]);
 }
 public function destroy($id, $taskId)
 {
     if (count(self::show($id, $taskId)) == 0) {
         return ['error' => true, 'message' => 'Nao encontrado'];
     } else {
         $this->repository->delete($taskId);
         return ['error' => true, 'message' => 'Nota ' . $taskId . ' do Projeto Excluido'];
     }
 }
 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 destroy($project_id, $task_id)
 {
     try {
         $this->repository->delete($task_id);
         #acento aqui funcionou normal
         return "Nota id:{$task_id} deletado com sucesso";
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => 'A tarefa que está tentando deletar não existe'];
     }
 }
 public function destroy($taskId)
 {
     try {
         $this->repository->delete($taskId);
     } catch (ValidatorException $e) {
         return response()->json(['error' => true, 'message' => $e->getMessageBag()]);
     } catch (ModelNotFoundException $e) {
         return response()->json(['error' => true, 'message1' => $e->getMessage(), 'message2' => 'Project Task ID ' . $taskId . ' nao encontrado.']);
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @param $taskId
  * @return Response
  */
 public function show($id, $taskId)
 {
     try {
         //$project = $this->repository->findWhere(['project_id' => $id, 'id' => $taskId]);
         $project = $this->repository->find($taskId);
         return $project;
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => 'ProjectNote not found'];
     }
 }
 public function delete($id)
 {
     try {
         if ($this->repository->delete($id)) {
             return ['success' => true, 'message' => 'Tarefa apagado com sucesso!'];
         }
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => 'Não foi possível apagar a tarefa! Projeto ou tarefa não encontrado!'];
     }
 }
 /**
  * @param $taskId
  * @return array
  */
 public function destroy($taskId)
 {
     try {
         if ($this->repository->delete($taskId)) {
             return ['success' => true, 'message' => 'Registro excluído'];
         }
         return ['error' => true, 'message' => 'Erro desconhecido ao tentar excluir o registro'];
     } catch (\Exception $e) {
         return ["error" => true, "message" => $e->getMessage()];
     }
 }
 public function delete($taskId)
 {
     try {
         $projectTask = $this->repository->skipPresenter()->find($taskId);
         if ($projectTask->delete()) {
             return ['error' => false, 'message' => 'Registro deletado com sucesso.'];
         }
     } catch (\Exception $e) {
         return ['error' => true, 'message' => 'Não foi possivel deletar o registro.'];
     }
 }
 /**
  * @param array $data
  * @param $projectId
  * @return array|mixed
  */
 public function create(array $data, $projectId)
 {
     try {
         $data['project_id'] = $projectId;
         $this->validator->with($data)->passesOrFail();
         return $this->repository->create($data);
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag()];
     } catch (\Exception $e) {
         return ["error" => true, "message" => $e->getMessage()];
     }
 }
 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()];
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  *
  * @return \Illuminate\Http\Response
  */
 public function destroy($id, $taskId)
 {
     if ($this->projectService->checkProjectPermissions($id) == false) {
         return ['error' => 'Access forbidden'];
     }
     $this->repository->skipPresenter()->find($taskId)->delete();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     try {
         $this->repository->find($id)->delete();
     } catch (ModelNotFoundException $e) {
         return "Task not found";
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id, $idTask)
 {
     return $this->repository->find($idTask);
     /*
     $result = $this->repository->findWhere(['project_id' => $id, 'id' => $idTask]);
     if(isset($result['data']) && count($result['data']) == 1){
         $result = [
             'data' => $result['data'][0]
         ];
     }
     return $result;
     /*
     
     if($this->checkProjectTaskPermissions($projectId) == false){
         return ['error' => 'Access Forbidden'];
     }
     
     return $this->repository->find($id);
     */
 }
 public function delete($id, $taskId)
 {
     try {
         $this->repository->delete($taskId);
         return ['success' => true];
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => 'No data found.'];
     } catch (\Exception $e) {
         return ['error' => true, 'message' => 'An error occurred when trying to delete the data. Try again later.'];
     }
 }
 /**
  * @param $id
  * @return \Illuminate\Http\JsonResponse
  */
 public function destroy($id)
 {
     try {
         $this->repository->delete($id);
         $msg = "Tarefa {$id} removida com sucesso.";
         Log::info($msg);
         return response()->json([$msg], 200);
     } catch (ModelNotFoundException $e) {
         return response()->json([$e->getMessage()], 404);
     }
     //QueryException tratado em Exceptions/Handler.php
 }
 public function removeTask($project_id, $task_id)
 {
     try {
         $this->taskRepository->find($task_id)->delete();
         return ['success' => true, 'message' => 'Tarefa deletada com sucesso!'];
     } catch (QueryException $e) {
         return $this->erroMsgm('Tarefa não pode ser apagado pois existe um projeto vinculado a ela.');
     } catch (ModelNotFoundException $e) {
         return $this->erroMsgm('Tarefa não encontrada.');
     } catch (\Exception $e) {
         return $this->erroMsgm('Ocorreu um erro ao excluir a tarefa.');
     }
 }
 public function delete($task_id)
 {
     $task = ProjectTask::find($task_id);
     if (is_null($task)) {
         return Errors::invalidId($task_id);
     }
     $user_id = \Authorizer::getResourceOwnerId();
     if (!$this->projectRepository->isMember($task->project_id, $user_id)) {
         return Errors::basic('Acesso negado. Você não é membro do projeto desta tarefa.');
     }
     $this->repository->delete($task_id);
     return ['message' => "Registro deletado!"];
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //return $this->repository->delete($taskId);
     $projectTask = $this->repository->skipPresenter()->find($id);
     //$result = $this->repository->delete($id);
     $projectId = $projectTask->project_id;
     if ($this->checkProjectTaskPermissions($projectId) == false) {
         return ['error' => 'Access Forbidden'];
     }
     $result = $projectTask->delete();
     if ($result) {
         return ['error' => 0];
     }
     return ['error' => 1, 'msg' => 'Erro ao tentar deletar a Task'];
 }
 public function delete($id)
 {
     $projectTask = $this->repository->skipPresenter()->find($id);
     return $projectTask->delete();
 }
 /**
  * Display a listing of the resource
  *
  * @param $id
  * @return Response
  */
 public function index($id)
 {
     return $this->repository->findWhere(['project_id' => $id]);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if ($this->repository->delete($id)) {
         return ['success' => true];
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id, $idTask)
 {
     return $this->repository->find($idTask);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param $task
  * @return Response
  * @internal param int $id
  */
 public function destroy($task)
 {
     if ($this->repository->delete($task)) {
         return 'Deletado';
     }
 }
 private function setPresenter()
 {
     $this->repository->setPresenter('CodeProject\\Presenters\\ProjectTaskPresenter');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($id)
 {
     $this->repository->find($id)->delete();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @param $taskId
  * @return \Illuminate\Http\Response
  */
 public function destroy($id, $taskId)
 {
     $this->repository->delete($taskId);
 }