<?php
namespace App\Entity;
use App\Repository\HotelRoomTypeRepository;
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: HotelRoomTypeRepository::class)]
class HotelRoomType extends ProductElement
{
#[ORM\Column(type: Types::SMALLINT)]
#[Assert\NotNull]
#[Assert\Positive]
#[Assert\Range(min: 1, max: 8)]
private ?int $minOccupancy = null;
#[ORM\Column(type: Types::SMALLINT)]
#[Assert\NotNull]
#[Assert\Positive]
#[Assert\Range(min: 1, max: 8)]
private ?int $maxOccupancy = null;
#[ORM\Column(type: Types::SMALLINT)]
#[Assert\NotNull]
#[Assert\PositiveOrZero]
#[Assert\Range(min: 0, max: 8)]
private ?int $minOccupancyAdult = null;
#[ORM\Column(type: Types::SMALLINT)]
#[Assert\NotNull]
#[Assert\PositiveOrZero]
#[Assert\Range(min: 0, max: 8)]
private ?int $maxOccupancyAdult= null;
#[ORM\ManyToMany(targetEntity: Facility::class, inversedBy: 'hotelRoomTypes')]
private $facilities;
#[ORM\ManyToOne(targetEntity: RoomType::class)]
private ?RoomType $roomType=null;
#[ORM\ManyToOne(targetEntity: Hotel::class, inversedBy: 'hotelRoomTypes')]
private ?Hotel $hotel;
#[ORM\ManyToMany(targetEntity: RoomOccupancy::class, inversedBy: 'hotelRoomTypes')]
private Collection $occupancies;
// #[ORM\OneToMany(mappedBy: 'hotelRoomType', targetEntity: ProductElementStockOperation::class)]
// private Collection $hotelRoomTypeAllotments;
// #[ORM\OneToMany(mappedBy: 'hotelRoomType', targetEntity: HotelRoomTypeArrangement::class, orphanRemoval: true)]
// private Collection $hotelRoomTypeArrangements;
public function __construct()
{
parent::__construct();
$this->facilities = new ArrayCollection();
$this->occupancies = new ArrayCollection();
// $this->hotelRoomTypeAllotments = new ArrayCollection();
// $this->hotelRoomTypeArrangements = new ArrayCollection();
}
public function getMinOccupancy(): ?int
{
return $this->minOccupancy;
}
public function setMinOccupancy(?int $minOccupancy): self
{
$this->minOccupancy = $minOccupancy;
return $this;
}
public function getMaxOccupancy(): ?int
{
return $this->maxOccupancy;
}
public function setMaxOccupancy(?int $maxOccupancy): self
{
$this->maxOccupancy = $maxOccupancy;
return $this;
}
public function getMinOccupancyAdult(): ?int
{
return $this->minOccupancyAdult;
}
public function setMinOccupancyAdult(?int $minOccupancyAdult): self
{
$this->minOccupancyAdult = $minOccupancyAdult;
return $this;
}
/**
* @return Collection<int, Facility>
*/
public function getFacilities(): Collection
{
return $this->facilities;
}
public function addFacility(Facility $facility): self
{
if (!$this->facilities->contains($facility)) {
$this->facilities[] = $facility;
}
return $this;
}
public function removeFacility(Facility $facility): self
{
$this->facilities->removeElement($facility);
return $this;
}
public function getRoomType(): ?RoomType
{
return $this->roomType;
}
public function setRoomType(?RoomType $roomType): self
{
$this->roomType = $roomType;
return $this;
}
public function getHotel(): ?Hotel
{
return $this->hotel;
}
public function setHotel(?Hotel $hotel): self
{
$this->hotel = $hotel;
return $this;
}
public function __toString(): string
{
return $this->getRoomType()->getName();
}
public function getMaxOccupancyAdult(): ?int
{
return $this->maxOccupancyAdult;
}
public function setMaxOccupancyAdult(?int $maxOccupancyAdult): self
{
$this->maxOccupancyAdult = $maxOccupancyAdult;
return $this;
}
/**
* @return Collection<int, RoomOccupancy>
*/
public function getOccupancies(): Collection
{
return $this->occupancies;
}
public function addOccupancy(RoomOccupancy $occupancy): self
{
if (!$this->occupancies->contains($occupancy)) {
$this->occupancies->add($occupancy);
}
return $this;
}
public function removeOccupancy(RoomOccupancy $occupancy): self
{
$this->occupancies->removeElement($occupancy);
return $this;
}
public function removeOccupancies(): self
{
$this->occupancies = new ArrayCollection();
return $this;
}
#[Assert\IsTrue(message: 'CheckOccupancies')]
public function isOccupGood(): bool
{
return $this->minOccupancy <= $this->maxOccupancy &&
$this->minOccupancyAdult <= $this->maxOccupancyAdult &&
$this->maxOccupancyAdult <= $this->maxOccupancy;
}
// /**
// * @return Collection<int, ProductElementStockOperation>
// */
// public function getHotelRoomTypeAllotments(): Collection
// {
// return $this->hotelRoomTypeAllotments;
// }
//
// public function addHotelRoomTypeAllotment(ProductElementStockOperation $hotelRoomTypeAllotment): self
// {
// if (!$this->hotelRoomTypeAllotments->contains($hotelRoomTypeAllotment)) {
// $this->hotelRoomTypeAllotments->add($hotelRoomTypeAllotment);
// $hotelRoomTypeAllotment->setHotelRoomType($this);
// }
//
// return $this;
// }
//
// public function removeHotelRoomTypeAllotment(ProductElementStockOperation $hotelRoomTypeAllotment): self
// {
// if ($this->hotelRoomTypeAllotments->removeElement($hotelRoomTypeAllotment)) {
// // set the owning side to null (unless already changed)
// if ($hotelRoomTypeAllotment->getHotelRoomType() === $this) {
// $hotelRoomTypeAllotment->setHotelRoomType(null);
// }
// }
//
// return $this;
// }
//
// /**
// * @return Collection<int, HotelRoomTypeArrangement>
// */
// public function getHotelRoomTypeArrangements(): Collection
// {
// return $this->hotelRoomTypeArrangements;
// }
//
// public function addHotelRoomTypeArrangement(HotelRoomTypeArrangement $hotelRoomTypeArrangement): self
// {
// if (!$this->hotelRoomTypeArrangements->contains($hotelRoomTypeArrangement)) {
// $this->hotelRoomTypeArrangements->add($hotelRoomTypeArrangement);
// $hotelRoomTypeArrangement->setHotelRoomType($this);
// }
//
// return $this;
// }
//
// public function removeHotelRoomTypeArrangement(HotelRoomTypeArrangement $hotelRoomTypeArrangement): self
// {
// if ($this->hotelRoomTypeArrangements->removeElement($hotelRoomTypeArrangement)) {
// // set the owning side to null (unless already changed)
// if ($hotelRoomTypeArrangement->getHotelRoomType() === $this) {
// $hotelRoomTypeArrangement->setHotelRoomType(null);
// }
// }
//
// return $this;
// }
}