src\Entity\Allergene.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use App\Repository\AllergeneRepository;
  7. #[ORM\Entity(repositoryClass: AllergeneRepository::class)]
  8. #[ORM\Table(name: '`allergene`')]
  9. class Allergene {
  10. #[ORM\Id]
  11. #[ORM\GeneratedValue]
  12. #[ORM\Column]
  13. private ?int $allergene_id = null;
  14. #[ORM\Column(type:"string",length: 50)]
  15. private ?string $libelle = null;
  16. #[ORM\OneToMany(targetEntity: Contient::class, mappedBy: 'allergene_id', orphanRemoval: true, cascade: ['persist'])]
  17. private Collection $contient;
  18. public function __construct()
  19. {
  20. $this->contient = new ArrayCollection();
  21. }
  22. public function getAllergeneId(): ?int
  23. {
  24. return $this->allergene_id;
  25. }
  26. public function setAllergeneId(int $allergene_id): static
  27. {
  28. $this->allergene_id = $allergene_id;
  29. return $this;
  30. }
  31. public function getLibelle(): ?string
  32. {
  33. return $this->libelle;
  34. }
  35. public function setLibelle(string $libelle): static
  36. {
  37. $this->libelle = $libelle;
  38. return $this;
  39. }
  40. /**
  41. * @return Collection<int, Contient>
  42. */
  43. public function getContients(): Collection
  44. {
  45. return $this->contient;
  46. }
  47. public function addContient(Contient $contient): static
  48. {
  49. if (!$this->contient->contains($contient)) {
  50. $this->contient->add($contient);
  51. $contient->setAllergeneId($this);
  52. }
  53. return $this;
  54. }
  55. public function removeContient(Contient $contient): static
  56. {
  57. if ($this->contient->removeElement($contient)) {
  58. // set the owning side to null (unless already changed)
  59. if ($contient->getAllergeneId() === $this) {
  60. $contient->setAllergeneId(null);
  61. }
  62. }
  63. return $this;
  64. }
  65. }