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, $taskId) { if ($this->repository->delete($taskId)) { return ['success' => true]; } else { return ['success' => false]; } }
public function destroy($id) { try { return $this->repository->delete($id); } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => 'Usuário que esta tentando deletar não existe']; } }
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 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 { $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 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) { try { $this->repository->delete($id); return ['message' => 'Delete client success']; } catch (\PDOException $e) { return ['error' => true, 'message' => $e->getMessage()]; } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => $e->getMessage()]; } }
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).']); } }
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) { try { $this->repository->delete($id); return ['success' => true, "message" => 'Registro excluído com sucesso.']; } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => 'Registro não encontrado.', "messageDev" => $e->getMessage()]; } catch (QueryException $e) { return ['error' => true, 'message' => 'Este registro não pode ser excluído, pois existe um ou mais projetos vinculados a ele.', "messageDev" => $e->getMessage()]; } catch (\Exception $e) { return ["error" => true, "message" => 'Falha ao excluir registro.', "messageDev" => $e->getMessage()]; } }
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()]; } }
/** * @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 }
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!']; } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { if ($this->repository->delete($id)) { return ['success' => true]; } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // Client::find($id)->delete(); return $this->repository->delete($id); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { return strval($this->repository->delete($id)); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $this->repository->delete($id); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { return ['success' => $this->repository->delete($id)]; //['success' => Client::find($id)->delete()]; }