src/Entity/HotelRoomType.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\HotelRoomTypeRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. #[ORM\Entity(repositoryClassHotelRoomTypeRepository::class)]
  10. class HotelRoomType extends ProductElement
  11. {
  12.     #[ORM\Column(typeTypes::SMALLINT)]
  13.     #[Assert\NotNull]
  14.     #[Assert\Positive]
  15.     #[Assert\Range(min1max8)]
  16.     private ?int $minOccupancy null;
  17.     #[ORM\Column(typeTypes::SMALLINT)]
  18.     #[Assert\NotNull]
  19.     #[Assert\Positive]
  20.     #[Assert\Range(min1max8)]
  21.     private ?int $maxOccupancy null;
  22.     #[ORM\Column(typeTypes::SMALLINT)]
  23.     #[Assert\NotNull]
  24.     #[Assert\PositiveOrZero]
  25.     #[Assert\Range(min0max8)]
  26.     private ?int $minOccupancyAdult null;
  27.     #[ORM\Column(typeTypes::SMALLINT)]
  28.     #[Assert\NotNull]
  29.     #[Assert\PositiveOrZero]
  30.     #[Assert\Range(min0max8)]
  31.     private ?int $maxOccupancyAdultnull;
  32.     #[ORM\ManyToMany(targetEntityFacility::class, inversedBy'hotelRoomTypes')]
  33.     private $facilities;
  34.     #[ORM\ManyToOne(targetEntityRoomType::class)]
  35.     private ?RoomType $roomType=null;
  36.     #[ORM\ManyToOne(targetEntityHotel::class, inversedBy'hotelRoomTypes')]
  37.     private ?Hotel $hotel;
  38.     #[ORM\ManyToMany(targetEntityRoomOccupancy::class, inversedBy'hotelRoomTypes')]
  39.     private Collection $occupancies;
  40. //    #[ORM\OneToMany(mappedBy: 'hotelRoomType', targetEntity: ProductElementStockOperation::class)]
  41. //    private Collection $hotelRoomTypeAllotments;
  42. //    #[ORM\OneToMany(mappedBy: 'hotelRoomType', targetEntity: HotelRoomTypeArrangement::class, orphanRemoval: true)]
  43. //    private Collection $hotelRoomTypeArrangements;
  44.     public function __construct()
  45.     {
  46.         parent::__construct();
  47.         $this->facilities = new ArrayCollection();
  48.         $this->occupancies = new ArrayCollection();
  49. //        $this->hotelRoomTypeAllotments = new ArrayCollection();
  50. //        $this->hotelRoomTypeArrangements = new ArrayCollection();
  51.     }
  52.     public function getMinOccupancy(): ?int
  53.     {
  54.         return $this->minOccupancy;
  55.     }
  56.     public function setMinOccupancy(?int $minOccupancy): self
  57.     {
  58.         $this->minOccupancy $minOccupancy;
  59.         return $this;
  60.     }
  61.     public function getMaxOccupancy(): ?int
  62.     {
  63.         return $this->maxOccupancy;
  64.     }
  65.     public function setMaxOccupancy(?int $maxOccupancy): self
  66.     {
  67.         $this->maxOccupancy $maxOccupancy;
  68.         return $this;
  69.     }
  70.     public function getMinOccupancyAdult(): ?int
  71.     {
  72.         return $this->minOccupancyAdult;
  73.     }
  74.     public function setMinOccupancyAdult(?int $minOccupancyAdult): self
  75.     {
  76.         $this->minOccupancyAdult $minOccupancyAdult;
  77.         return $this;
  78.     }
  79.     /**
  80.      * @return Collection<int, Facility>
  81.      */
  82.     public function getFacilities(): Collection
  83.     {
  84.         return $this->facilities;
  85.     }
  86.     public function addFacility(Facility $facility): self
  87.     {
  88.         if (!$this->facilities->contains($facility)) {
  89.             $this->facilities[] = $facility;
  90.         }
  91.         return $this;
  92.     }
  93.     public function removeFacility(Facility $facility): self
  94.     {
  95.         $this->facilities->removeElement($facility);
  96.         return $this;
  97.     }
  98.     public function getRoomType(): ?RoomType
  99.     {
  100.         return $this->roomType;
  101.     }
  102.     public function setRoomType(?RoomType $roomType): self
  103.     {
  104.         $this->roomType $roomType;
  105.         return $this;
  106.     }
  107.     public function getHotel(): ?Hotel
  108.     {
  109.         return $this->hotel;
  110.     }
  111.     public function setHotel(?Hotel $hotel): self
  112.     {
  113.         $this->hotel $hotel;
  114.         return $this;
  115.     }
  116.     public function __toString(): string
  117.     {
  118.         return $this->getRoomType()->getName();
  119.     }
  120.     public function getMaxOccupancyAdult(): ?int
  121.     {
  122.         return $this->maxOccupancyAdult;
  123.     }
  124.     public function setMaxOccupancyAdult(?int $maxOccupancyAdult): self
  125.     {
  126.         $this->maxOccupancyAdult $maxOccupancyAdult;
  127.         return $this;
  128.     }
  129.     /**
  130.      * @return Collection<int, RoomOccupancy>
  131.      */
  132.     public function getOccupancies(): Collection
  133.     {
  134.         return $this->occupancies;
  135.     }
  136.     public function addOccupancy(RoomOccupancy $occupancy): self
  137.     {
  138.         if (!$this->occupancies->contains($occupancy)) {
  139.             $this->occupancies->add($occupancy);
  140.         }
  141.         return $this;
  142.     }
  143.     public function removeOccupancy(RoomOccupancy $occupancy): self
  144.     {
  145.         $this->occupancies->removeElement($occupancy);
  146.         return $this;
  147.     }
  148.     public function removeOccupancies(): self
  149.     {
  150.         $this->occupancies = new ArrayCollection();
  151.         return $this;
  152.     }
  153.     #[Assert\IsTrue(message'CheckOccupancies')]
  154.     public function isOccupGood(): bool
  155.     {
  156.         return  $this->minOccupancy <= $this->maxOccupancy &&
  157.                 $this->minOccupancyAdult <= $this->maxOccupancyAdult &&
  158.                 $this->maxOccupancyAdult <= $this->maxOccupancy;
  159.     }
  160. }