src/Entity/Facility.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\FacilityRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. #[ORM\Entity(repositoryClassFacilityRepository::class)]
  10. #[UniqueEntity(fields: ['name'])]
  11. class Facility
  12. {
  13.     const TYPE_ROOM 'room';
  14.     const TYPE_HOTEL 'hotel';
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column(type'integer')]
  18.     private $id;
  19.     #[ORM\Column(type'string'length45)]
  20.     #[Assert\NotBlank]
  21.     #[Assert\Length(max45)]
  22.     #[Assert\Regex(
  23.         pattern'/^[\p{L}\p{M}0-9\s\'-]+$/u',
  24.     )]
  25.     private ?string $name;
  26.     #[ORM\Column(type'string'length255nullabletrue)]
  27.     #[Assert\NotBlank]
  28.     private ?string $description;
  29.     #[ORM\Column(type'integer'nullabletrue)]
  30.     private ?int $ordre;
  31.     #[ORM\ManyToMany(targetEntityHotelRoomType::class, mappedBy'facilities')]
  32.     private $hotelRoomTypes;
  33.     #[ORM\Column(length128 nullabletrue)]
  34.     private ?string $icon null;
  35.     #[ORM\Column(length255)]
  36.     private ?string $type null;
  37.     public function __construct()
  38.     {
  39.         $this->hotelRoomTypes = new ArrayCollection();
  40.         $this->hotels = new ArrayCollection();
  41.     }
  42.     public function getId(): ?int
  43.     {
  44.         return $this->id;
  45.     }
  46.     public function getName(): ?string
  47.     {
  48.         return $this->name;
  49.     }
  50.     public function setName(?string $name): self
  51.     {
  52.         $this->name $name;
  53.         return $this;
  54.     }
  55.     public function getDescription(): ?string
  56.     {
  57.         return $this->description;
  58.     }
  59.     public function setDescription(?string $description): self
  60.     {
  61.         $this->description $description;
  62.         return $this;
  63.     }
  64.     public function getOrdre(): ?int
  65.     {
  66.         return $this->ordre;
  67.     }
  68.     public function setOrdre(?int $ordre): self
  69.     {
  70.         $this->ordre $ordre;
  71.         return $this;
  72.     }
  73.     /**
  74.      * @return Collection<int, HotelRoomType>
  75.      */
  76.     public function getHotelRoomTypes(): Collection
  77.     {
  78.         return $this->hotelRoomTypes;
  79.     }
  80.     public function addHotelRoomType(HotelRoomType $hotelRoomType): self
  81.     {
  82.         if (!$this->hotelRoomTypes->contains($hotelRoomType)) {
  83.             $this->hotelRoomTypes[] = $hotelRoomType;
  84.             $hotelRoomType->addFacility($this);
  85.         }
  86.         return $this;
  87.     }
  88.     public function removeHotelRoomType(HotelRoomType $hotelRoomType): self
  89.     {
  90.         if ($this->hotelRoomTypes->removeElement($hotelRoomType)) {
  91.             $hotelRoomType->removeFacility($this);
  92.         }
  93.         return $this;
  94.     }
  95.     public function __toString(): string
  96.     {
  97.         return (string) $this->name;
  98.     }
  99.     public function getIcon(): ?string
  100.     {
  101.         return $this->icon;
  102.     }
  103.     public function setIcon(string $icon): self
  104.     {
  105.         $this->icon $icon;
  106.         return $this;
  107.     }
  108.     public function getType(): ?string
  109.     {
  110.         return $this->type;
  111.     }
  112.     public function setType(string $type): self
  113.     {
  114.         $this->type $type;
  115.         return $this;
  116.     }
  117. }