public function deleteOrFail($client_id) { if (Client::find($client_id)) { return $this->find($client_id)->delete(); } return "Error: client not found"; }
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) { $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!"]; }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { Client::find($id)->delete(); }