public function destroy($id) { if (count(self::show($id)) == 0) { return ['error' => true, 'message' => 'Nao encontrado']; } else { /* return $this->repository->with(['project'])->findWhere(['id' => $id]); if ( count($this->repository->with(['project'])->findWhere(['client_id' => $id])) > 0 ) { return [ 'error' => true, 'message' => 'Este Cliente tem Projetos' ]; } else { return $this->repository->delete( $id); }*/ try { return $this->repository->delete($id); return ['status' => true, 'message' => 'Projeto excluído com sucesso']; } catch (\PDOException $e) { return ['status' => false, 'message' => 'Não foi possível excluir o cliente']; } } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $c = $this->repository->find($id)->delete(); if ($c) { return "O projeto {$id} foi deletado com sucesso!"; } }
public function show($id) { try { return $this->repository->find($id); } catch (Exception $e) { return ['error' => true, 'message' => $e->getMessage()]; } }
public function show($id) { try { return $this->repository->find($id); } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => 'Usuario nao existe']; } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id, $taskId) { if ($this->repository->delete($taskId)) { return ['success' => true]; } else { return ['success' => false]; } }
public function destroy($id) { try { $this->repository->find($id); } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => 'Cliente não encontrado.']; } return $this->repository->delete($id); }
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($data, $id) { try { $this->validator->with($data)->passesOrFail(); return $this->repository->update($data, $id); } catch (ValidatorException $ex) { return ['success' => false, 'message' => $ex->getMessageBag()]; } }
public function destroy($id) { try { $this->repository->delete($id); #acento aqui funcionou normal return "Usuário {$id} deletado com sucesso"; } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => 'Usuario que está tentando deletar não existe']; } }
public function delete($id) { try { if ($this->repository->delete($id)) { return ['error' => false, 'message' => 'Registro deletado com sucesso.']; } } catch (\Exception $e) { return ['error' => true, 'message' => 'Não foi possivel deletar o registro.']; } }
/** * @param $id * @return array */ public function destroy($id) { try { if ($this->repository->delete($id)) { return ['success' => true]; } } catch (\Exception $e) { return ["error" => true, "message" => $e->getMessage()]; } }
public function destroy($id) { try { return $this->repository->delete($id); } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => 'Não foi possível encontrar o cliente.']; } catch (QueryException $e) { return ['error' => true, 'message' => 'Atenção! Não é possível excluir o cliente. Cliente possui projetos vinculados a ele.']; } }
/** * 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' => 'Client removed']; } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => 'Client not Found']; } catch (QueryException $e) { return ['error' => true, 'message' => 'This client has related projects']; } }
public function delete($id) { $entity = Client::find($id); if (is_null($entity)) { return Errors::invalidId($id); } foreach ($entity->projects as $proj) { $this->projectService->delete($proj->id); } $this->repository->delete($id); return ['message' => "Registro deletado!"]; }
public function delete($id) { $projects = $this->projectRepository->findByField('client_id', $id); foreach ($projects as $project) { $this->projectRepository->delete($project->id); } $response = $this->repository->delete($id); if ($response === true) { return ['success' => true]; } return $response; }
public function delete($id) { $entity = Client::find($id); if (is_null($entity)) { return Errors::invalidId($id); } if (count($entity->projects) > 0) { return Errors::basic("Este cliente possui projetos. Exclusão cancelada."); } $this->repository->delete($id); return ['message' => "Registro deletado!"]; }
public function destroy($id) { try { $this->repository->delete($id); } catch (ValidatorException $e) { return response()->json(['error' => true, 'message' => $e->getMessageBag()]); } catch (ModelNotFoundException $e) { return response()->json(['error' => true, 'message1' => $e->getMessage(), 'message2' => 'Cliente ID ' . $id . ' nao encontrado.']); } catch (QueryException $e) { return response()->json(['error' => true, 'message1' => $e->getMessage(), 'message2' => 'Cliente ID ' . $id . ' possui projetos atrelados a ele. Primeiro exclua o(s) projeto(s).']); } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $client = $this->repository->find($id); if ($client) { $client->delete(); $msg['status'] = "Y"; $msg['message'] = "Successfully deleted record"; } else { $msg['status'] = "N"; $msg['message'] = "record already deleted or invalid"; } return $msg; }
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 Response */ public function destroy($id) { //$result = $this->repository->find($id)->delete(); $result = $this->repository->skipPresenter()->find($id)->delete(); if ($result) { return ['error' => 0]; } return ['error' => 1, 'msg' => 'Erro ao tentar deletar o Cliente']; }
public function delete($id) { try { return $this->repository->delete($id); } catch (\Exception $e) { switch (get_class($e)) { case 'Illuminate\\Database\\Eloquent\\ModelNotFoundException': $message = 'The client does not exist'; break; case 'Illuminate\\Database\\QueryException': $message = 'The client can not be deleted'; break; default: $message = $e->getMessage(); } return ['error' => true, 'message' => $message]; } }
/** * Delete the client * * @param integer $id client id * @return json */ public function delete($id) { try { $this->repository->find($id)->projects()->delete(); $this->repository->delete($id); return ['success' => true]; } catch (\Exception $e) { return ["error" => true, "message" => $e->getMessage()]; } }
public function destroy($id) { try { $this->repository->skipPresenter()->find($id)->delete(); return ['deleted' => 'true']; } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => 'No data found for id:' . $id]; } catch (QueryException $e) { return ['error' => true, 'message' => 'You cannot delete this data, there is register related!']; } }
/** * @param $id * @return \Illuminate\Http\JsonResponse */ public function destroy($id) { try { $this->repository->delete($id); $msg = "Cliente {$id} removido 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 }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { try { $this->repository->skipPresenter()->find($id)->delete(); return ['success' => true, 'message' => "Cliente deletado com sucesso!"]; } catch (QueryException $e) { return $this->erroMsgm('Cliente não pode ser apagado pois existe um ou mais projetos vinculados a ele.'); } catch (ModelNotFoundException $e) { return $this->erroMsgm('Cliente não encontrado.'); } catch (\Exception $e) { return $this->erroMsgm('Ocorreu um erro ao excluir o cliente.'); } }
public function delete($id) { try { $this->repository->delete($id)->with('projects')->find($id); return ['success' => true]; } catch (QueryException $e) { return ['error' => true, 'message' => 'Client can not be deleted because there are one or more projects linked to it.']; } 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.']; } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { //return Client::find($id)->delete(); //return $this->repository->delete($id); try { if ($this->repository->delete($id)) { return ['success' => true, 'message' => 'Cliente apagado com sucesso']; } } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => 'Não foi possível apagar o cliente! Cliente não encontrado!']; } catch (QueryException $e) { return ['error' => true, 'message' => 'Existem projetos atrelado a este cliente. Cliente não Apagado!']; } }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { return $this->repository->skipPresenter()->find($id); }
public function createFile(array $data) { $project = $this->repository->skipPresenter()->find($data['project_id']); $projectFile = $project->files()->create($data); $this->storage->put($projectFile->id . '.' . $data['extension'], $this->filesystem->get($data['file'])); }
public function destroy($id) { $this->repository->find($id)->delete(); }