src\Entity\Regime.php line 13

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\RegimeRepository;
  7. #[ORM\Entity(repositoryClass: RegimeRepository::class)]
  8. #[ORM\Table(name: '`regime`')]
  9. class Regime {
  10. #[ORM\Id]
  11. #[ORM\GeneratedValue]
  12. #[ORM\Column]
  13. private ?int $regime_id = null;
  14. #[ORM\Column(type:"string",length: 50)]
  15. private ?string $libelle = null;
  16. #[ORM\OneToMany(targetEntity: Adapte::class, mappedBy: 'regime_id', orphanRemoval: true, cascade: ['persist'])]
  17. private Collection $adaptes;
  18. public function __construct()
  19. {
  20. $this->adaptes = new ArrayCollection();
  21. }
  22. public function getRegimeId(): ?int
  23. {
  24. return $this->regime_id;
  25. }
  26. public function setRegimeId(int $regime_id): static
  27. {
  28. $this->regime_id = $regime_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, Adapte>
  42. */
  43. public function getAdaptes(): Collection
  44. {
  45. return $this->adaptes;
  46. }
  47. public function addAdapte(Adapte $adapte): static
  48. {
  49. if (!$this->adaptes->contains($adapte)) {
  50. $this->adaptes->add($adapte);
  51. $adapte->setRegimeId($this);
  52. }
  53. return $this;
  54. }
  55. public function removeAdapte(Adapte $adapte): static
  56. {
  57. if ($this->adaptes->removeElement($adapte)) {
  58. // set the owning side to null (unless already changed)
  59. if ($adapte->getRegimeId() === $this) {
  60. $adapte->setRegimeId(null);
  61. }
  62. }
  63. return $this;
  64. }
  65. }