src/Entity/Residence.php line 15

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ResidenceRepository;
  4. use App\Traits\TimeStampTrait;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. #[ORM\Entity(repositoryClassResidenceRepository::class)]
  10. #[ORM\HasLifecycleCallbacks]
  11. class Residence
  12. {
  13.     use TimeStampTrait;
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column(type'integer')]
  17.     private $id;
  18.     #[ORM\Column(length100)]
  19.     private ?string $code null;
  20.     #[ORM\Column(length100nullabletrue)]
  21.     private ?string $libelle null;
  22.     #[ORM\ManyToOne(inversedBy'residences')]
  23.     private ?User $createdBy null;
  24.     #[ORM\Column(length255)]
  25.     private ?string $adress null;
  26.     #[ORM\Column(nullabletrue)]
  27.     private ?bool $status null;
  28.     #[ORM\OneToMany(mappedBy'residence'targetEntityHabitat::class, cascade: ['all'], fetch'EAGER')]
  29.     private Collection $habitats;
  30.     #[ORM\Column(length100nullabletrue)]
  31.     private ?string $number null;
  32.     #[ORM\Column(length100nullabletrue)]
  33.     private ?string $commune null;
  34.     #[ORM\Column(length100nullabletrue)]
  35.     private ?string $ville null;
  36.     #[ORM\ManyToOne(inversedBy'residences')]
  37.     private ?Entreprise $marchand null;
  38.     #[ORM\OneToMany(mappedBy'residence'targetEntityPhotos::class)]
  39.     private Collection $photos;
  40.     #[ORM\ManyToMany(targetEntityResidenceDetails::class, inversedBy'residences')]
  41.     private Collection $details;
  42.     #[ORM\ManyToMany(targetEntityCategoryResidence::class, inversedBy'residences')]
  43.     private Collection $category;
  44.     #[ORM\ManyToOne(inversedBy'residences')]
  45.     private ?ResidenceImmeuble $immeuble null;
  46.     #[ORM\OneToMany(mappedBy'residence'targetEntityResidenceImmeuble::class)]
  47.     private Collection $residenceImmeubles;
  48.     #[ORM\ManyToOne(inversedBy'residences')]
  49.     #[Assert\NotBlank(message'Veuillez renseigner ce champ')]
  50.     private ?Country $country null;
  51.     #[ORM\ManyToOne(inversedBy'residences')]
  52.     #[Assert\NotBlank(message'Veuillez renseigner ce champ')]
  53.     private ?Province $province null;
  54.     #[ORM\OneToMany(mappedBy'residence'targetEntityIncident::class)]
  55.     private Collection $incidents;
  56.     #[ORM\Column(length255nullabletrue)]
  57.     private ?string $pointdereference null;
  58.     #[ORM\Column(length50nullabletrue)]
  59.     private ?string $codepostal null;
  60.     #[ORM\OneToMany(mappedBy'residence'targetEntityCharge::class)]
  61.     private Collection $charges;
  62.     #[ORM\OneToMany(mappedBy'residence'targetEntityLocation::class)]
  63.     private Collection $locations;
  64.     public function __construct()
  65.     {
  66.         $this->habitats = new ArrayCollection();
  67.         $this->category = new ArrayCollection();
  68.         $this->photos = new ArrayCollection();
  69.         $this->details = new ArrayCollection();
  70.         $this->residenceImmeubles = new ArrayCollection();
  71.         $this->incidents = new ArrayCollection();
  72.         $this->charges = new ArrayCollection();
  73.         $this->locations = new ArrayCollection();
  74.     }
  75.     /**
  76.      * Set id.
  77.      *
  78.      * @param int $id
  79.      *
  80.      * @return Residence
  81.      */
  82.     public function setId($id): static
  83.     {
  84.         $this->id $id;
  85.         return $this;
  86.     }
  87.     public function getId()
  88.     {
  89.         return $this->id;
  90.     }
  91.     /**
  92.      * @return string|null
  93.      */
  94.     public function getCode(): ?string
  95.     {
  96.         return $this->code;
  97.     }
  98.     /**
  99.      * @param string|null $code
  100.      */
  101.     public function setCode(?string $code): void
  102.     {
  103.         $this->code $code;
  104.     }
  105.     /**
  106.      * @return string|null
  107.      */
  108.     public function getLibelle(): ?string
  109.     {
  110.         return $this->libelle;
  111.     }
  112.     /**
  113.      * @param string|null $libelle
  114.      */
  115.     public function setLibelle(?string $libelle): void
  116.     {
  117.         $this->libelle $libelle;
  118.     }
  119.     /**
  120.      * @return User|null
  121.      */
  122.     public function getCreatedBy(): ?User
  123.     {
  124.         return $this->createdBy;
  125.     }
  126.     /**
  127.      * @param User|null $createdBy
  128.      */
  129.     public function setCreatedBy(?User $createdBy): void
  130.     {
  131.         $this->createdBy $createdBy;
  132.     }
  133.     /**
  134.      * @return string|null
  135.      */
  136.     public function getAdress(): ?string
  137.     {
  138.         return $this->adress;
  139.     }
  140.     /**
  141.      * @param string|null $adress
  142.      */
  143.     public function setAdress(?string $adress): void
  144.     {
  145.         $this->adress $adress;
  146.     }
  147.     /**
  148.      * @return bool|null
  149.      */
  150.     public function getStatus(): ?bool
  151.     {
  152.         return $this->status;
  153.     }
  154.     /**
  155.      * @param bool|null $status
  156.      */
  157.     public function setStatus(?bool $status): void
  158.     {
  159.         $this->status $status;
  160.     }
  161.     /**
  162.      * @return ArrayCollection|Collection
  163.      */
  164.     public function getHabitats(): ArrayCollection|Collection
  165.     {
  166.         return $this->habitats;
  167.     }
  168.     /**
  169.      * @param ArrayCollection|Collection $habitats
  170.      */
  171.     public function setHabitats(ArrayCollection|Collection $habitats): void
  172.     {
  173.         $this->habitats $habitats;
  174.     }
  175.     /**
  176.      * @return string|null
  177.      */
  178.     public function getNumber(): ?string
  179.     {
  180.         return $this->number;
  181.     }
  182.     /**
  183.      * @param string|null $number
  184.      */
  185.     public function setNumber(?string $number): void
  186.     {
  187.         $this->number $number;
  188.     }
  189.     /**
  190.      * @return string|null
  191.      */
  192.     public function getCommune(): ?string
  193.     {
  194.         return $this->commune;
  195.     }
  196.     /**
  197.      * @param string|null $commune
  198.      */
  199.     public function setCommune(?string $commune): void
  200.     {
  201.         $this->commune $commune;
  202.     }
  203.     /**
  204.      * @return string|null
  205.      */
  206.     public function getVille(): ?string
  207.     {
  208.         return $this->ville;
  209.     }
  210.     /**
  211.      * @param string|null $ville
  212.      */
  213.     public function setVille(?string $ville): void
  214.     {
  215.         $this->ville $ville;
  216.     }
  217.     /**
  218.      * @return Entreprise|null
  219.      */
  220.     public function getMarchand(): ?Entreprise
  221.     {
  222.         return $this->marchand;
  223.     }
  224.     /**
  225.      * @param Entreprise|null $marchand
  226.      */
  227.     public function setMarchand(?Entreprise $marchand): void
  228.     {
  229.         $this->marchand $marchand;
  230.     }
  231.     /**
  232.      * @return ArrayCollection|Collection
  233.      */
  234.     public function getPhotos(): ArrayCollection|Collection
  235.     {
  236.         return $this->photos;
  237.     }
  238.     /**
  239.      * @param ArrayCollection|Collection $photos
  240.      */
  241.     public function setPhotos(ArrayCollection|Collection $photos): void
  242.     {
  243.         $this->photos $photos;
  244.     }
  245.     public function __toString()
  246.     {
  247.         return $this->libelle;
  248.     }
  249.     /**
  250.      * @return Collection<int, ResidenceDetails>
  251.      */
  252.     public function getDetails(): Collection
  253.     {
  254.         return $this->details;
  255.     }
  256.     public function addDetail(ResidenceDetails $detail): static
  257.     {
  258.         if (!$this->details->contains($detail)) {
  259.             $this->details->add($detail);
  260.         }
  261.         return $this;
  262.     }
  263.     public function removeDetail(ResidenceDetails $detail): static
  264.     {
  265.         $this->details->removeElement($detail);
  266.         return $this;
  267.     }
  268.     /**
  269.      * @return Collection<int, CategoryResidence>
  270.      */
  271.     public function getCategory(): Collection
  272.     {
  273.         return $this->category;
  274.     }
  275.     public function addCategory(CategoryResidence $category): static
  276.     {
  277.         if (!$this->category->contains($category)) {
  278.             $this->category->add($category);
  279.         }
  280.         return $this;
  281.     }
  282.     public function removeCategory(CategoryResidence $category): static
  283.     {
  284.         $this->category->removeElement($category);
  285.         return $this;
  286.     }
  287.     public function getImmeuble(): ?ResidenceImmeuble
  288.     {
  289.         return $this->immeuble;
  290.     }
  291.     public function setImmeuble(?ResidenceImmeuble $immeuble): static
  292.     {
  293.         $this->immeuble $immeuble;
  294.         return $this;
  295.     }
  296.     /**
  297.      * @return Collection<int, ResidenceImmeuble>
  298.      */
  299.     public function getResidenceImmeubles(): Collection
  300.     {
  301.         return $this->residenceImmeubles;
  302.     }
  303.     public function addResidenceImmeuble(ResidenceImmeuble $residenceImmeuble): static
  304.     {
  305.         if (!$this->residenceImmeubles->contains($residenceImmeuble)) {
  306.             $this->residenceImmeubles->add($residenceImmeuble);
  307.             $residenceImmeuble->setResidence($this);
  308.         }
  309.         return $this;
  310.     }
  311.     public function removeResidenceImmeuble(ResidenceImmeuble $residenceImmeuble): static
  312.     {
  313.         if ($this->residenceImmeubles->removeElement($residenceImmeuble)) {
  314.             // set the owning side to null (unless already changed)
  315.             if ($residenceImmeuble->getResidence() === $this) {
  316.                 $residenceImmeuble->setResidence(null);
  317.             }
  318.         }
  319.         return $this;
  320.     }
  321.     public function getCountry(): ?Country
  322.     {
  323.         return $this->country;
  324.     }
  325.     public function setCountry(?Country $country): static
  326.     {
  327.         $this->country $country;
  328.         return $this;
  329.     }
  330.     public function getProvince(): ?Province
  331.     {
  332.         return $this->province;
  333.     }
  334.     public function setProvince(?Province $province): static
  335.     {
  336.         $this->province $province;
  337.         return $this;
  338.     }
  339.     /**
  340.      * @return Collection<int, Incident>
  341.      */
  342.     public function getIncidents(): Collection
  343.     {
  344.         return $this->incidents;
  345.     }
  346.     public function addIncident(Incident $incident): static
  347.     {
  348.         if (!$this->incidents->contains($incident)) {
  349.             $this->incidents->add($incident);
  350.             $incident->setResidence($this);
  351.         }
  352.         return $this;
  353.     }
  354.     public function removeIncident(Incident $incident): static
  355.     {
  356.         if ($this->incidents->removeElement($incident)) {
  357.             // set the owning side to null (unless already changed)
  358.             if ($incident->getResidence() === $this) {
  359.                 $incident->setResidence(null);
  360.             }
  361.         }
  362.         return $this;
  363.     }
  364.     public function getPointdereference(): ?string
  365.     {
  366.         return $this->pointdereference;
  367.     }
  368.     public function setPointdereference(?string $pointdereference): static
  369.     {
  370.         $this->pointdereference $pointdereference;
  371.         return $this;
  372.     }
  373.     public function getCodepostal(): ?string
  374.     {
  375.         return $this->codepostal;
  376.     }
  377.     public function setCodepostal(?string $codepostal): static
  378.     {
  379.         $this->codepostal $codepostal;
  380.         return $this;
  381.     }
  382.     /**
  383.      * @return Collection<int, Charge>
  384.      */
  385.     public function getCharges(): Collection
  386.     {
  387.         return $this->charges;
  388.     }
  389.     public function addCharge(Charge $charge): static
  390.     {
  391.         if (!$this->charges->contains($charge)) {
  392.             $this->charges->add($charge);
  393.             $charge->setResidence($this);
  394.         }
  395.         return $this;
  396.     }
  397.     public function removeCharge(Charge $charge): static
  398.     {
  399.         if ($this->charges->removeElement($charge)) {
  400.             // set the owning side to null (unless already changed)
  401.             if ($charge->getResidence() === $this) {
  402.                 $charge->setResidence(null);
  403.             }
  404.         }
  405.         return $this;
  406.     }
  407.     /**
  408.      * @return Collection<int, Location>
  409.      */
  410.     public function getLocations(): Collection
  411.     {
  412.         return $this->locations;
  413.     }
  414.     public function addLocation(Location $location): static
  415.     {
  416.         if (!$this->locations->contains($location)) {
  417.             $this->locations->add($location);
  418.             $location->setResidence($this);
  419.         }
  420.         return $this;
  421.     }
  422.     public function removeLocation(Location $location): static
  423.     {
  424.         if ($this->locations->removeElement($location)) {
  425.             // set the owning side to null (unless already changed)
  426.             if ($location->getResidence() === $this) {
  427.                 $location->setResidence(null);
  428.             }
  429.         }
  430.         return $this;
  431.     }
  432. }