<?phpnamespace App\Entity;use App\Repository\FacilityRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use Symfony\Component\Validator\Constraints as Assert;#[ORM\Entity(repositoryClass: FacilityRepository::class)]#[UniqueEntity(fields: ['name'])]class Facility{ const TYPE_ROOM = 'room'; const TYPE_HOTEL = 'hotel'; #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: 'integer')] private $id; #[ORM\Column(type: 'string', length: 45)] #[Assert\NotBlank] #[Assert\Length(max: 45)] #[Assert\Regex( pattern: '/^[\p{L}\p{M}0-9\s\'-]+$/u', )] private ?string $name; #[ORM\Column(type: 'string', length: 255, nullable: true)] #[Assert\NotBlank] private ?string $description; #[ORM\Column(type: 'integer', nullable: true)] private ?int $ordre; #[ORM\ManyToMany(targetEntity: HotelRoomType::class, mappedBy: 'facilities')] private $hotelRoomTypes; #[ORM\Column(length: 128 , nullable: true)] private ?string $icon = null; #[ORM\Column(length: 255)] private ?string $type = null; public function __construct() { $this->hotelRoomTypes = new ArrayCollection(); $this->hotels = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(?string $name): self { $this->name = $name; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(?string $description): self { $this->description = $description; return $this; } public function getOrdre(): ?int { return $this->ordre; } public function setOrdre(?int $ordre): self { $this->ordre = $ordre; return $this; } /** * @return Collection<int, HotelRoomType> */ public function getHotelRoomTypes(): Collection { return $this->hotelRoomTypes; } public function addHotelRoomType(HotelRoomType $hotelRoomType): self { if (!$this->hotelRoomTypes->contains($hotelRoomType)) { $this->hotelRoomTypes[] = $hotelRoomType; $hotelRoomType->addFacility($this); } return $this; } public function removeHotelRoomType(HotelRoomType $hotelRoomType): self { if ($this->hotelRoomTypes->removeElement($hotelRoomType)) { $hotelRoomType->removeFacility($this); } return $this; } public function __toString(): string { return (string) $this->name; } public function getIcon(): ?string { return $this->icon; } public function setIcon(string $icon): self { $this->icon = $icon; return $this; } public function getType(): ?string { return $this->type; } public function setType(string $type): self { $this->type = $type; return $this; }}