Implemented entities for new RoomCategory BedType system.

This commit is contained in:
2024-09-10 18:08:40 +02:00
parent 09f384fce0
commit 975d0495a8
12 changed files with 469 additions and 57 deletions
+37 -15
View File
@@ -22,9 +22,6 @@ class RoomCategory
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
#[ORM\Column(length: 64, nullable: true)]
private ?string $bedType = null;
#[ORM\Column(nullable: false)]
private ?int $maxGuestNum = null;
@@ -34,9 +31,16 @@ class RoomCategory
#[ORM\OneToMany(targetEntity: RoomCategoryPhoto::class, mappedBy: 'roomCategory', orphanRemoval: true, cascade: ['persist'])]
private Collection $roomCategoryPhotos;
/**
* @var Collection<int, RoomCategoryBedType>
*/
#[ORM\OneToMany(targetEntity: RoomCategoryBedType::class, mappedBy: 'roomCategory', orphanRemoval: true, cascade: ['persist'])]
private Collection $roomCategoryBedTypes;
public function __construct()
{
$this->roomCategoryPhotos = new ArrayCollection();
$this->roomCategoryBedTypes = new ArrayCollection();
}
public function getId(): ?int
@@ -68,18 +72,6 @@ class RoomCategory
return $this;
}
public function getBedType(): ?string
{
return $this->bedType;
}
public function setBedType(?string $bedType): static
{
$this->bedType = $bedType;
return $this;
}
public function getMaxGuestNum(): ?int
{
return $this->maxGuestNum;
@@ -126,4 +118,34 @@ class RoomCategory
{
return $this->name;
}
/**
* @return Collection<int, RoomCategoryBedType>
*/
public function getRoomCategoryBedTypes(): Collection
{
return $this->roomCategoryBedTypes;
}
public function addRoomCategoryBedType(RoomCategoryBedType $roomCategoryBedType): static
{
if (!$this->roomCategoryBedTypes->contains($roomCategoryBedType)) {
$this->roomCategoryBedTypes->add($roomCategoryBedType);
$roomCategoryBedType->setRoomCategory($this);
}
return $this;
}
public function removeRoomCategoryBedType(RoomCategoryBedType $roomCategoryBedType): static
{
if ($this->roomCategoryBedTypes->removeElement($roomCategoryBedType)) {
// set the owning side to null (unless already changed)
if ($roomCategoryBedType->getRoomCategory() === $this) {
$roomCategoryBedType->setRoomCategory(null);
}
}
return $this;
}
}