Implemented entities for new RoomCategory BedType system.
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\BedTypeRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: BedTypeRepository::class)]
|
||||
class BedType
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $name = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $iconUrl = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIconUrl(): ?string
|
||||
{
|
||||
return $this->iconUrl;
|
||||
}
|
||||
|
||||
public function setIconUrl(?string $iconUrl): static
|
||||
{
|
||||
$this->iconUrl = $iconUrl;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+37
-15
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\RoomCategoryBedTypeRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: RoomCategoryBedTypeRepository::class)]
|
||||
class RoomCategoryBedType
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\ManyToOne(inversedBy: 'roomCategoryBedTypes')]
|
||||
#[ORM\JoinColumn(nullable: false, onDelete: "CASCADE")]
|
||||
private ?RoomCategory $roomCategory = null;
|
||||
|
||||
#[ORM\Id]
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?BedType $bedType = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $amount = null;
|
||||
|
||||
public function __construct(RoomCategory $roomCat, BedType $bedType) {
|
||||
$this->roomCategory = $roomCat;
|
||||
$this->bedType = $bedType;
|
||||
}
|
||||
|
||||
public function getAmount(): ?int
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
public function setAmount(int $amount): static
|
||||
{
|
||||
$this->amount = $amount;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRoomCategory(): ?RoomCategory
|
||||
{
|
||||
return $this->roomCategory;
|
||||
}
|
||||
|
||||
public function setRoomCategory(?RoomCategory $roomCategory): static
|
||||
{
|
||||
$this->roomCategory = $roomCategory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBedType(): ?BedType
|
||||
{
|
||||
return $this->bedType;
|
||||
}
|
||||
|
||||
public function setBedType(?BedType $bedType): static
|
||||
{
|
||||
$this->bedType = $bedType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user