src/Entity/ResidenceImmeuble.php line 11

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ResidenceImmeubleRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassResidenceImmeubleRepository::class)]
  8. class ResidenceImmeuble
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length100)]
  15.     private ?string $code null;
  16.     #[ORM\Column(length50)]
  17.     private ?string $libelle null;
  18.     #[ORM\OneToMany(mappedBy'immeuble'targetEntityResidence::class)]
  19.     private Collection $residences;
  20.     #[ORM\ManyToOne(inversedBy'residenceImmeubles')]
  21.     private ?Entreprise $marchand null;
  22.     #[ORM\ManyToOne(inversedBy'residenceImmeubles')]
  23.     private ?Residence $residence null;
  24.     #[ORM\OneToMany(mappedBy'immeuble'targetEntityHabitat::class)]
  25.     private Collection $habitats;
  26.     public function __construct()
  27.     {
  28.         $this->residences = new ArrayCollection();
  29.         $this->habitats = new ArrayCollection();
  30.     }
  31.     public function getId(): ?int
  32.     {
  33.         return $this->id;
  34.     }
  35.     public function getCode(): ?string
  36.     {
  37.         return $this->code;
  38.     }
  39.     public function setCode(string $code): static
  40.     {
  41.         $this->code $code;
  42.         return $this;
  43.     }
  44.     public function getLibelle(): ?string
  45.     {
  46.         return $this->libelle;
  47.     }
  48.     public function setLibelle(string $libelle): static
  49.     {
  50.         $this->libelle $libelle;
  51.         return $this;
  52.     }
  53.     /**
  54.      * @return Collection<int, Residence>
  55.      */
  56.     public function getResidences(): Collection
  57.     {
  58.         return $this->residences;
  59.     }
  60.     public function addResidence(Residence $residence): static
  61.     {
  62.         if (!$this->residences->contains($residence)) {
  63.             $this->residences->add($residence);
  64.             $residence->setImmeuble($this);
  65.         }
  66.         return $this;
  67.     }
  68.     public function removeResidence(Residence $residence): static
  69.     {
  70.         if ($this->residences->removeElement($residence)) {
  71.             // set the owning side to null (unless already changed)
  72.             if ($residence->getImmeuble() === $this) {
  73.                 $residence->setImmeuble(null);
  74.             }
  75.         }
  76.         return $this;
  77.     }
  78.     public function getMarchand(): ?Entreprise
  79.     {
  80.         return $this->marchand;
  81.     }
  82.     public function setMarchand(?Entreprise $marchand): static
  83.     {
  84.         $this->marchand $marchand;
  85.         return $this;
  86.     }
  87.     public function getResidence(): ?Residence
  88.     {
  89.         return $this->residence;
  90.     }
  91.     public function setResidence(?Residence $residence): static
  92.     {
  93.         $this->residence $residence;
  94.         return $this;
  95.     }
  96.     /**
  97.      * @return Collection<int, Habitat>
  98.      */
  99.     public function getHabitats(): Collection
  100.     {
  101.         return $this->habitats;
  102.     }
  103.     public function addHabitat(Habitat $habitat): static
  104.     {
  105.         if (!$this->habitats->contains($habitat)) {
  106.             $this->habitats->add($habitat);
  107.             $habitat->setImmeuble($this);
  108.         }
  109.         return $this;
  110.     }
  111.     public function removeHabitat(Habitat $habitat): static
  112.     {
  113.         if ($this->habitats->removeElement($habitat)) {
  114.             // set the owning side to null (unless already changed)
  115.             if ($habitat->getImmeuble() === $this) {
  116.                 $habitat->setImmeuble(null);
  117.             }
  118.         }
  119.         return $this;
  120.     }
  121. }