src/Entity/Habitat.php line 17
<?phpnamespace App\Entity;use App\Repository\HabitatRepository;use App\Traits\TimeStampTrait;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Validator\Constraints as Assert;#[ORM\Entity(repositoryClass: HabitatRepository::class)]#[ORM\Table(name: 'Habitat')]#[ORM\HasLifecycleCallbacks]class Habitat{use TimeStampTrait;#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column(type: 'integer')]private $id;#[ORM\ManyToOne(cascade: ['all'], fetch: 'EAGER', inversedBy: 'habitats')]private ?Residence $residence = null;#[ORM\Column(length: 100)]private ?string $code = null;#[ORM\Column(length: 100)]private ?string $libelle = null;#[ORM\Column(type: Types::DECIMAL, precision: 10, scale: 2)]private ?string $loyer = null;#[ORM\Column]private ?bool $status = null;#[ORM\ManyToOne(inversedBy: 'habitats')]private ?User $createdBy = null;#[ORM\OneToMany(mappedBy: 'habitat', targetEntity: Location::class)]private Collection $locations;#[ORM\Column]private ?bool $occuper = null;#[ORM\ManyToOne(inversedBy: 'habitats')]private ?Devise $devise = null;#[ORM\Column(length: 100, nullable: true)]private ?string $number = null;#[ORM\ManyToOne(inversedBy: 'habitats')]private ?Entreprise $marchand = null;#[ORM\Column(length: 50, nullable: true)]private ?string $type = null;#[ORM\Column(length: 255, nullable: true)]private ?string $Description = null;#[ORM\ManyToOne(inversedBy: 'habitats')]private ?HabitatDetails $details = null;#[ORM\OneToMany(mappedBy: 'habitat', targetEntity: Photos::class)]private Collection $photos;#[ORM\OneToMany(mappedBy: 'habitat', targetEntity: HabitatDetails::class, cascade: ['all'], fetch: 'EAGER')]private Collection $habitatDetails;#[ORM\ManyToOne(inversedBy: 'habitats')]private ?CategoryHabitat $category = null;#[ORM\ManyToOne(inversedBy: 'habitats')]private ?ResidenceImmeuble $immeuble = null;#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]private ?\DateTimeInterface $freeAt = null;#[ORM\OneToMany(mappedBy: 'habitat', targetEntity: Amenities::class)]private Collection $amenities;#[ORM\Column(nullable: true)]private ?bool $publish = null;#[ORM\Column(length: 100, nullable: true)]private ?string $publicationtitle = null;#[ORM\OneToMany(mappedBy: 'habitat', targetEntity: Charge::class)]private Collection $charges;#[ORM\Column(type: Types::DECIMAL, precision: 10, scale: 2, nullable: true)]private ?string $surfaceArea = null;#[ORM\Column(nullable: true)]private ?int $livingroom = null;#[ORM\Column(nullable: true)]private ?int $bedroom = null;#[ORM\Column(nullable: true)]private ?int $bathroom = null;#[ORM\Column(nullable: true)]private ?int $floor = null;#[ORM\Column(nullable: true)]private ?int $garage = null;#[ORM\Column(length: 25, nullable: true)]private ?string $ShortFrequency = null;#[ORM\Column(length: 25, nullable: true, options: ['default' => 'long_term'])]private ?string $rentalTerm = null; // 'long_term' | 'short_term' | 'mixte'#[ORM\OneToMany(mappedBy: "habitat", targetEntity: HabitatPrice::class, cascade: ["persist", "remove"], orphanRemoval: true)]private Collection $prices;#[ORM\Column(nullable: true)]private ?int $kitchen = null;#[ORM\Column(nullable: true)]private ?int $watercloset = null;#[ORM\Column(nullable: true)]private ?int $balcon = null;public function __construct(){$this->locations = new ArrayCollection();$this->photos = new ArrayCollection();$this->habitatDetails = new ArrayCollection();$this->amenities = new ArrayCollection();$this->charges = new ArrayCollection();$this->prices = new ArrayCollection();}/*** Set id.** @param int $id** @return Habitat*/public function setId($id){$this->id = $id;return $this;}public function getId(){return $this->id;}/*** @return Residence|null*/public function getResidence(): ?Residence{return $this->residence;}/*** @param Residence|null $residence*/public function setResidence(?Residence $residence): void{$this->residence = $residence;}/*** @return string|null*/public function getCode(): ?string{return $this->code;}/*** @param string|null $code*/public function setCode(?string $code): void{$this->code = $code;}/*** @return string|null*/public function getLibelle(): ?string{return $this->libelle;}/*** @param string|null $libelle*/public function setLibelle(?string $libelle): void{$this->libelle = $libelle;}/*** @return string|null*/public function getLoyer(): ?string{return $this->loyer;}/*** @param string|null $loyer*/public function setLoyer(?string $loyer): void{$this->loyer = $loyer;}/*** @return bool|null*/public function getStatus(): ?bool{return $this->status;}/*** @param bool|null $status*/public function setStatus(?bool $status): void{$this->status = $status;}/*** @return User|null*/public function getCreatedBy(): ?User{return $this->createdBy;}/*** @param User|null $createdBy*/public function setCreatedBy(?User $createdBy): void{$this->createdBy = $createdBy;}/*** @return ArrayCollection|Collection*/public function getLocations(): ArrayCollection|Collection{return $this->locations;}/*** @param ArrayCollection|Collection $locations*/public function setLocations(ArrayCollection|Collection $locations): void{$this->locations = $locations;}/*** @return bool|null*/public function getOccuper(): ?bool{return $this->occuper;}/*** @param bool|null $occuper*/public function setOccuper(?bool $occuper): void{$this->occuper = $occuper;}/*** @return Devise|null*/public function getDevise(): ?Devise{return $this->devise;}/*** @param Devise|null $devise*/public function setDevise(?Devise $devise): void{$this->devise = $devise;}/*** @return string|null*/public function getNumber(): ?string{return $this->number;}/*** @param string|null $number*/public function setNumber(?string $number): void{$this->number = $number;}/*** @return Entreprise|null*/public function getMarchand(): ?Entreprise{return $this->marchand;}/*** @param Entreprise|null $marchand*/public function setMarchand(?Entreprise $marchand): void{$this->marchand = $marchand;}/*** @return string|null*/public function getType(): ?string{return $this->type;}/*** @param string|null $type*/public function setType(?string $type): void{$this->type = $type;}/*** @return string|null*/public function getDescription(): ?string{return $this->Description;}/*** @param string|null $Description*/public function setDescription(?string $Description): void{$this->Description = $Description;}/*** @return HabitatDetails|null*/public function getDetails(): ?HabitatDetails{return $this->details;}/*** @param HabitatDetails|null $details*/public function setDetails(?HabitatDetails $details): void{$this->details = $details;}/*** @return ArrayCollection|Collection*/public function getPhotos(): ArrayCollection|Collection{return $this->photos;}/*** @param ArrayCollection|Collection $photos*/public function setPhotos(ArrayCollection|Collection $photos): void{$this->photos = $photos;}/*** @return ArrayCollection|Collection*/public function getHabitatDetails(): ArrayCollection|Collection{return $this->habitatDetails;}/*** @param ArrayCollection|Collection $habitatDetails*/public function setHabitatDetails(ArrayCollection|Collection $habitatDetails): void{$this->habitatDetails = $habitatDetails;}public function getCategory(): ?CategoryHabitat{return $this->category;}public function setCategory(?CategoryHabitat $category): static{$this->category = $category;return $this;}public function getImmeuble(): ?ResidenceImmeuble{return $this->immeuble;}public function setImmeuble(?ResidenceImmeuble $immeuble): static{$this->immeuble = $immeuble;return $this;}public function getFreeAt(): ?\DateTimeInterface{return $this->freeAt;}public function setFreeAt(?\DateTimeInterface $freeAt): static{$this->freeAt = $freeAt;return $this;}/*** @return Collection<int, Amenities>*/public function getAmenities(): Collection{return $this->amenities;}public function addAmenity(Amenities $amenity): static{if (!$this->amenities->contains($amenity)) {$this->amenities->add($amenity);$amenity->setHabitat($this);}return $this;}public function removeAmenity(Amenities $amenity): static{if ($this->amenities->removeElement($amenity)) {// set the owning side to null (unless already changed)if ($amenity->getHabitat() === $this) {$amenity->setHabitat(null);}}return $this;}public function isPublish(): ?bool{return $this->publish;}public function setPublish(?bool $publish): static{$this->publish = $publish;return $this;}public function getPublicationtitle(): ?string{return $this->publicationtitle;}public function setPublicationtitle(?string $publicationtitle): static{$this->publicationtitle = $publicationtitle;return $this;}/*** @return Collection<int, Charge>*/public function getCharges(): Collection{return $this->charges;}public function addCharge(Charge $charge): static{if (!$this->charges->contains($charge)) {$this->charges->add($charge);$charge->setHabitat($this);}return $this;}public function removeCharge(Charge $charge): static{if ($this->charges->removeElement($charge)) {// set the owning side to null (unless already changed)if ($charge->getHabitat() === $this) {$charge->setHabitat(null);}}return $this;}public function getSurfaceArea(): ?string{return $this->surfaceArea;}public function setSurfaceArea(?string $surfaceArea): static{$this->surfaceArea = $surfaceArea;return $this;}public function getLivingroom(): ?int{return $this->livingroom;}public function setLivingroom(?int $livingroom): static{$this->livingroom = $livingroom;return $this;}public function getBedroom(): ?int{return $this->bedroom;}public function setBedroom(?int $bedroom): static{$this->bedroom = $bedroom;return $this;}public function getBathroom(): ?int{return $this->bathroom;}public function setBathroom(?int $bathroom): static{$this->bathroom = $bathroom;return $this;}public function getFloor(): ?int{return $this->floor;}public function setFloor(?int $floor): static{$this->floor = $floor;return $this;}public function getGarage(): ?int{return $this->garage;}public function setGarage(?int $garage): static{$this->garage = $garage;return $this;}public function __toString(): string{// Prefer a human label, then other identifiers, then a generic label$label = $this->getLibelle() // e.g. "Studio A12"?? $this->getCode() // code/string identifier?? null;if ($label !== null && $label !== '') {return (string) $label;}// Show ID if available (useful in admin lists)if ($this->getId()) {return 'Habitat #'.$this->getId();}// Brand-new (unsaved) entitiesreturn 'Habitat (nouveau)';}public function getShortFrequency(): ?string{return $this->ShortFrequency;}public function setShortFrequency(?string $ShortFrequency): static{$this->ShortFrequency = $ShortFrequency;return $this;}public function getRentalTerm(): ?string{return $this->rentalTerm;}public function setRentalTerm(?string $rentalTerm): static{$this->rentalTerm = $rentalTerm;return $this;}public function getPrices(): Collection{return $this->prices;}public function addPrice(HabitatPrice $price): self{if (!$this->prices->contains($price)) {$this->prices[] = $price;$price->setHabitat($this);}return $this;}public function removePrice(HabitatPrice $price): self{if ($this->prices->removeElement($price)) {if ($price->getHabitat() === $this) {$price->setHabitat(null);}}return $this;}public function getPriceForType(string $type): ?HabitatPrice{foreach ($this->prices as $price) {if ($price->getRentalTerm() === $type) {return $price;}}return null;}public function getKitchen(): ?int{return $this->kitchen;}public function setKitchen(?int $kitchen): static{$this->kitchen = $kitchen;return $this;}public function getWatercloset(): ?int{return $this->watercloset;}public function setWatercloset(?int $watercloset): static{$this->watercloset = $watercloset;return $this;}public function getBalcon(): ?int{return $this->balcon;}public function setBalcon(?int $balcon): static{$this->balcon = $balcon;return $this;}}