variableRepository = $variableRepository; $this->entityManager = $entityManager; } /** * @param int $id * * @return bool|string */ public function delete(int $id, string $typeField) { $result = false; if($typeField == "variable"){ $variable = $this->variableRepository->findById($id); if(!empty($variable) && $variable instanceof Variable){ $result = $this->variableRepository->delete($variable); } elseif(empty($variable)) { $result = "No variable found for id ".$id; } else { $result = $variable; } } else { $inputRepo = $this->entityManager->getRepository(Input::class); $input = $inputRepo->findOneBy([ "id" => $id, "deletedAt" => null ]); if(!empty($input) && $input instanceof Input){ try { $this->entityManager->remove($input); $this->entityManager->flush(); $result = true; } catch (Exception $e) { $result = $e->getMessage(); } } else { $result = "No input found for id ".$id; } } return $result; } }