src/Entity/Habitat.php line 17

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\HabitatRepository;
  4. use App\Traits\TimeStampTrait;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. #[ORM\Entity(repositoryClassHabitatRepository::class)]
  11. #[ORM\Table(name'Habitat')]
  12. #[ORM\HasLifecycleCallbacks]
  13. class Habitat
  14. {
  15.     use TimeStampTrait;
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column(type'integer')]
  19.     private $id;
  20.     #[ORM\ManyToOne(cascade: ['all'], fetch'EAGER'inversedBy'habitats')]
  21.     private ?Residence $residence null;
  22.     #[ORM\Column(length100)]
  23.     private ?string $code null;
  24.     #[ORM\Column(length100)]
  25.     private ?string $libelle null;
  26.     #[ORM\Column(typeTypes::DECIMALprecision10scale2)]
  27.     private ?string $loyer null;
  28.     #[ORM\Column]
  29.     private ?bool $status null;
  30.     #[ORM\ManyToOne(inversedBy'habitats')]
  31.     private ?User $createdBy null;
  32.     #[ORM\OneToMany(mappedBy'habitat'targetEntityLocation::class)]
  33.     private Collection $locations;
  34.     #[ORM\Column]
  35.     private ?bool $occuper null;
  36.     #[ORM\ManyToOne(inversedBy'habitats')]
  37.     private ?Devise $devise null;
  38.     #[ORM\Column(length100nullabletrue)]
  39.     private ?string $number null;
  40.     #[ORM\ManyToOne(inversedBy'habitats')]
  41.     private ?Entreprise $marchand null;
  42.     #[ORM\Column(length50nullabletrue)]
  43.     private ?string $type null;
  44.     #[ORM\Column(length255nullabletrue)]
  45.     private ?string $Description null;
  46.     #[ORM\ManyToOne(inversedBy'habitats')]
  47.     private ?HabitatDetails $details null;
  48.     #[ORM\OneToMany(mappedBy'habitat'targetEntityPhotos::class)]
  49.     private Collection $photos;
  50.     #[ORM\OneToMany(mappedBy'habitat'targetEntityHabitatDetails::class, cascade: ['all'], fetch'EAGER')]
  51.     private Collection $habitatDetails;
  52.     #[ORM\ManyToOne(inversedBy'habitats')]
  53.     private ?CategoryHabitat $category null;
  54.     #[ORM\ManyToOne(inversedBy'habitats')]
  55.     private ?ResidenceImmeuble $immeuble null;
  56.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  57.     private ?\DateTimeInterface $freeAt null;
  58.     #[ORM\OneToMany(mappedBy'habitat'targetEntityAmenities::class)]
  59.     private Collection $amenities;
  60.     #[ORM\Column(nullabletrue)]
  61.     private ?bool $publish null;
  62.     #[ORM\Column(length100nullabletrue)]
  63.     private ?string $publicationtitle null;
  64.     #[ORM\OneToMany(mappedBy'habitat'targetEntityCharge::class)]
  65.     private Collection $charges;
  66.     #[ORM\Column(typeTypes::DECIMALprecision10scale2nullabletrue)]
  67.     private ?string $surfaceArea null;
  68.     #[ORM\Column(nullabletrue)]
  69.     private ?int $livingroom null;
  70.     #[ORM\Column(nullabletrue)]
  71.     private ?int $bedroom null;
  72.     #[ORM\Column(nullabletrue)]
  73.     private ?int $bathroom null;
  74.     #[ORM\Column(nullabletrue)]
  75.     private ?int $floor null;
  76.     #[ORM\Column(nullabletrue)]
  77.     private ?int $garage null;
  78.     #[ORM\Column(length25nullabletrue)]
  79.     private ?string $ShortFrequency null;
  80.     #[ORM\Column(length25nullabletrueoptions: ['default' => 'long_term'])]
  81.     private ?string $rentalTerm null// 'long_term' | 'short_term' | 'mixte'
  82.     #[ORM\OneToMany(mappedBy"habitat"targetEntityHabitatPrice::class, cascade: ["persist""remove"], orphanRemovaltrue)]
  83.     private Collection $prices;
  84.     #[ORM\Column(nullabletrue)]
  85.     private ?int $kitchen null;
  86.     #[ORM\Column(nullabletrue)]
  87.     private ?int $watercloset null;
  88.     #[ORM\Column(nullabletrue)]
  89.     private ?int $balcon null;
  90.     public function __construct()
  91.     {
  92.         $this->locations = new ArrayCollection();
  93.         $this->photos = new ArrayCollection();
  94.         $this->habitatDetails = new ArrayCollection();
  95.         $this->amenities = new ArrayCollection();
  96.         $this->charges = new ArrayCollection();
  97.         $this->prices = new ArrayCollection();
  98.     }
  99.     /**
  100.      * Set id.
  101.      *
  102.      * @param int $id
  103.      *
  104.      * @return Habitat
  105.      */
  106.     public function setId($id)
  107.     {
  108.         $this->id $id;
  109.         return $this;
  110.     }
  111.     public function getId()
  112.     {
  113.         return $this->id;
  114.     }
  115.     /**
  116.      * @return Residence|null
  117.      */
  118.     public function getResidence(): ?Residence
  119.     {
  120.         return $this->residence;
  121.     }
  122.     /**
  123.      * @param Residence|null $residence
  124.      */
  125.     public function setResidence(?Residence $residence): void
  126.     {
  127.         $this->residence $residence;
  128.     }
  129.     /**
  130.      * @return string|null
  131.      */
  132.     public function getCode(): ?string
  133.     {
  134.         return $this->code;
  135.     }
  136.     /**
  137.      * @param string|null $code
  138.      */
  139.     public function setCode(?string $code): void
  140.     {
  141.         $this->code $code;
  142.     }
  143.     /**
  144.      * @return string|null
  145.      */
  146.     public function getLibelle(): ?string
  147.     {
  148.         return $this->libelle;
  149.     }
  150.     /**
  151.      * @param string|null $libelle
  152.      */
  153.     public function setLibelle(?string $libelle): void
  154.     {
  155.         $this->libelle $libelle;
  156.     }
  157.     /**
  158.      * @return string|null
  159.      */
  160.     public function getLoyer(): ?string
  161.     {
  162.         return $this->loyer;
  163.     }
  164.     /**
  165.      * @param string|null $loyer
  166.      */
  167.     public function setLoyer(?string $loyer): void
  168.     {
  169.         $this->loyer $loyer;
  170.     }
  171.     /**
  172.      * @return bool|null
  173.      */
  174.     public function getStatus(): ?bool
  175.     {
  176.         return $this->status;
  177.     }
  178.     /**
  179.      * @param bool|null $status
  180.      */
  181.     public function setStatus(?bool $status): void
  182.     {
  183.         $this->status $status;
  184.     }
  185.     /**
  186.      * @return User|null
  187.      */
  188.     public function getCreatedBy(): ?User
  189.     {
  190.         return $this->createdBy;
  191.     }
  192.     /**
  193.      * @param User|null $createdBy
  194.      */
  195.     public function setCreatedBy(?User $createdBy): void
  196.     {
  197.         $this->createdBy $createdBy;
  198.     }
  199.     /**
  200.      * @return ArrayCollection|Collection
  201.      */
  202.     public function getLocations(): ArrayCollection|Collection
  203.     {
  204.         return $this->locations;
  205.     }
  206.     /**
  207.      * @param ArrayCollection|Collection $locations
  208.      */
  209.     public function setLocations(ArrayCollection|Collection $locations): void
  210.     {
  211.         $this->locations $locations;
  212.     }
  213.     /**
  214.      * @return bool|null
  215.      */
  216.     public function getOccuper(): ?bool
  217.     {
  218.         return $this->occuper;
  219.     }
  220.     /**
  221.      * @param bool|null $occuper
  222.      */
  223.     public function setOccuper(?bool $occuper): void
  224.     {
  225.         $this->occuper $occuper;
  226.     }
  227.     /**
  228.      * @return Devise|null
  229.      */
  230.     public function getDevise(): ?Devise
  231.     {
  232.         return $this->devise;
  233.     }
  234.     /**
  235.      * @param Devise|null $devise
  236.      */
  237.     public function setDevise(?Devise $devise): void
  238.     {
  239.         $this->devise $devise;
  240.     }
  241.     /**
  242.      * @return string|null
  243.      */
  244.     public function getNumber(): ?string
  245.     {
  246.         return $this->number;
  247.     }
  248.     /**
  249.      * @param string|null $number
  250.      */
  251.     public function setNumber(?string $number): void
  252.     {
  253.         $this->number $number;
  254.     }
  255.     /**
  256.      * @return Entreprise|null
  257.      */
  258.     public function getMarchand(): ?Entreprise
  259.     {
  260.         return $this->marchand;
  261.     }
  262.     /**
  263.      * @param Entreprise|null $marchand
  264.      */
  265.     public function setMarchand(?Entreprise $marchand): void
  266.     {
  267.         $this->marchand $marchand;
  268.     }
  269.     /**
  270.      * @return string|null
  271.      */
  272.     public function getType(): ?string
  273.     {
  274.         return $this->type;
  275.     }
  276.     /**
  277.      * @param string|null $type
  278.      */
  279.     public function setType(?string $type): void
  280.     {
  281.         $this->type $type;
  282.     }
  283.     /**
  284.      * @return string|null
  285.      */
  286.     public function getDescription(): ?string
  287.     {
  288.         return $this->Description;
  289.     }
  290.     /**
  291.      * @param string|null $Description
  292.      */
  293.     public function setDescription(?string $Description): void
  294.     {
  295.         $this->Description $Description;
  296.     }
  297.     /**
  298.      * @return HabitatDetails|null
  299.      */
  300.     public function getDetails(): ?HabitatDetails
  301.     {
  302.         return $this->details;
  303.     }
  304.     /**
  305.      * @param HabitatDetails|null $details
  306.      */
  307.     public function setDetails(?HabitatDetails $details): void
  308.     {
  309.         $this->details $details;
  310.     }
  311.     /**
  312.      * @return ArrayCollection|Collection
  313.      */
  314.     public function getPhotos(): ArrayCollection|Collection
  315.     {
  316.         return $this->photos;
  317.     }
  318.     /**
  319.      * @param ArrayCollection|Collection $photos
  320.      */
  321.     public function setPhotos(ArrayCollection|Collection $photos): void
  322.     {
  323.         $this->photos $photos;
  324.     }
  325.     /**
  326.      * @return ArrayCollection|Collection
  327.      */
  328.     public function getHabitatDetails(): ArrayCollection|Collection
  329.     {
  330.         return $this->habitatDetails;
  331.     }
  332.     /**
  333.      * @param ArrayCollection|Collection $habitatDetails
  334.      */
  335.     public function setHabitatDetails(ArrayCollection|Collection $habitatDetails): void
  336.     {
  337.         $this->habitatDetails $habitatDetails;
  338.     }
  339.     public function getCategory(): ?CategoryHabitat
  340.     {
  341.         return $this->category;
  342.     }
  343.     public function setCategory(?CategoryHabitat $category): static
  344.     {
  345.         $this->category $category;
  346.         return $this;
  347.     }
  348.     public function getImmeuble(): ?ResidenceImmeuble
  349.     {
  350.         return $this->immeuble;
  351.     }
  352.     public function setImmeuble(?ResidenceImmeuble $immeuble): static
  353.     {
  354.         $this->immeuble $immeuble;
  355.         return $this;
  356.     }
  357.     public function getFreeAt(): ?\DateTimeInterface
  358.     {
  359.         return $this->freeAt;
  360.     }
  361.     public function setFreeAt(?\DateTimeInterface $freeAt): static
  362.     {
  363.         $this->freeAt $freeAt;
  364.         return $this;
  365.     }
  366.     /**
  367.      * @return Collection<int, Amenities>
  368.      */
  369.     public function getAmenities(): Collection
  370.     {
  371.         return $this->amenities;
  372.     }
  373.     public function addAmenity(Amenities $amenity): static
  374.     {
  375.         if (!$this->amenities->contains($amenity)) {
  376.             $this->amenities->add($amenity);
  377.             $amenity->setHabitat($this);
  378.         }
  379.         return $this;
  380.     }
  381.     public function removeAmenity(Amenities $amenity): static
  382.     {
  383.         if ($this->amenities->removeElement($amenity)) {
  384.             // set the owning side to null (unless already changed)
  385.             if ($amenity->getHabitat() === $this) {
  386.                 $amenity->setHabitat(null);
  387.             }
  388.         }
  389.         return $this;
  390.     }
  391.     public function isPublish(): ?bool
  392.     {
  393.         return $this->publish;
  394.     }
  395.     public function setPublish(?bool $publish): static
  396.     {
  397.         $this->publish $publish;
  398.         return $this;
  399.     }
  400.     public function getPublicationtitle(): ?string
  401.     {
  402.         return $this->publicationtitle;
  403.     }
  404.     public function setPublicationtitle(?string $publicationtitle): static
  405.     {
  406.         $this->publicationtitle $publicationtitle;
  407.         return $this;
  408.     }
  409.     /**
  410.      * @return Collection<int, Charge>
  411.      */
  412.     public function getCharges(): Collection
  413.     {
  414.         return $this->charges;
  415.     }
  416.     public function addCharge(Charge $charge): static
  417.     {
  418.         if (!$this->charges->contains($charge)) {
  419.             $this->charges->add($charge);
  420.             $charge->setHabitat($this);
  421.         }
  422.         return $this;
  423.     }
  424.     public function removeCharge(Charge $charge): static
  425.     {
  426.         if ($this->charges->removeElement($charge)) {
  427.             // set the owning side to null (unless already changed)
  428.             if ($charge->getHabitat() === $this) {
  429.                 $charge->setHabitat(null);
  430.             }
  431.         }
  432.         return $this;
  433.     }
  434.     public function getSurfaceArea(): ?string
  435.     {
  436.         return $this->surfaceArea;
  437.     }
  438.     public function setSurfaceArea(?string $surfaceArea): static
  439.     {
  440.         $this->surfaceArea $surfaceArea;
  441.         return $this;
  442.     }
  443.     public function getLivingroom(): ?int
  444.     {
  445.         return $this->livingroom;
  446.     }
  447.     public function setLivingroom(?int $livingroom): static
  448.     {
  449.         $this->livingroom $livingroom;
  450.         return $this;
  451.     }
  452.     public function getBedroom(): ?int
  453.     {
  454.         return $this->bedroom;
  455.     }
  456.     public function setBedroom(?int $bedroom): static
  457.     {
  458.         $this->bedroom $bedroom;
  459.         return $this;
  460.     }
  461.     public function getBathroom(): ?int
  462.     {
  463.         return $this->bathroom;
  464.     }
  465.     public function setBathroom(?int $bathroom): static
  466.     {
  467.         $this->bathroom $bathroom;
  468.         return $this;
  469.     }
  470.     public function getFloor(): ?int
  471.     {
  472.         return $this->floor;
  473.     }
  474.     public function setFloor(?int $floor): static
  475.     {
  476.         $this->floor $floor;
  477.         return $this;
  478.     }
  479.     public function getGarage(): ?int
  480.     {
  481.         return $this->garage;
  482.     }
  483.     public function setGarage(?int $garage): static
  484.     {
  485.         $this->garage $garage;
  486.         return $this;
  487.     }
  488.     public function __toString(): string
  489.     {
  490.         // Prefer a human label, then other identifiers, then a generic label
  491.         $label $this->getLibelle()            // e.g. "Studio A12"
  492.             ?? $this->getCode()              // code/string identifier
  493.             ?? null;
  494.         if ($label !== null && $label !== '') {
  495.             return (string) $label;
  496.         }
  497.         // Show ID if available (useful in admin lists)
  498.         if ($this->getId()) {
  499.             return 'Habitat #'.$this->getId();
  500.         }
  501.         // Brand-new (unsaved) entities
  502.         return 'Habitat (nouveau)';
  503.     }
  504.     public function getShortFrequency(): ?string
  505.     {
  506.         return $this->ShortFrequency;
  507.     }
  508.     public function setShortFrequency(?string $ShortFrequency): static
  509.     {
  510.         $this->ShortFrequency $ShortFrequency;
  511.         return $this;
  512.     }
  513.     public function getRentalTerm(): ?string
  514.     {
  515.         return $this->rentalTerm;
  516.     }
  517.     public function setRentalTerm(?string $rentalTerm): static
  518.     {
  519.         $this->rentalTerm $rentalTerm;
  520.         return $this;
  521.     }
  522.     public function getPrices(): Collection
  523.     {
  524.         return $this->prices;
  525.     }
  526.     public function addPrice(HabitatPrice $price): self
  527.     {
  528.         if (!$this->prices->contains($price)) {
  529.             $this->prices[] = $price;
  530.             $price->setHabitat($this);
  531.         }
  532.         return $this;
  533.     }
  534.     public function removePrice(HabitatPrice $price): self
  535.     {
  536.         if ($this->prices->removeElement($price)) {
  537.             if ($price->getHabitat() === $this) {
  538.                 $price->setHabitat(null);
  539.             }
  540.         }
  541.         return $this;
  542.     }
  543.     public function getPriceForType(string $type): ?HabitatPrice
  544.     {
  545.         foreach ($this->prices as $price) {
  546.             if ($price->getRentalTerm() === $type) {
  547.                 return $price;
  548.             }
  549.         }
  550.         return null;
  551.     }
  552.     public function getKitchen(): ?int
  553.     {
  554.         return $this->kitchen;
  555.     }
  556.     public function setKitchen(?int $kitchen): static
  557.     {
  558.         $this->kitchen $kitchen;
  559.         return $this;
  560.     }
  561.     public function getWatercloset(): ?int
  562.     {
  563.         return $this->watercloset;
  564.     }
  565.     public function setWatercloset(?int $watercloset): static
  566.     {
  567.         $this->watercloset $watercloset;
  568.         return $this;
  569.     }
  570.     public function getBalcon(): ?int
  571.     {
  572.         return $this->balcon;
  573.     }
  574.     public function setBalcon(?int $balcon): static
  575.     {
  576.         $this->balcon $balcon;
  577.         return $this;
  578.     }
  579. }