<?php
namespace App\Entity;
use App\Repository\RoomRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Table(name: '`escappart_room`')]
#[ORM\Entity(repositoryClass: RoomRepository::class)]
class Room
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $color = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $bedsId = null;
#[ORM\ManyToOne(inversedBy: 'rooms', cascade: ['persist', 'remove'])]
#[ORM\JoinColumn(nullable: false)]
private ?Hotel $hotel = null;
#[ORM\OneToMany(mappedBy: 'room', targetEntity: Booking::class, orphanRemoval: true)]
private Collection $bookings;
#[ORM\OneToMany(mappedBy: 'room', targetEntity: SeasonalFinance::class)]
#[ORM\OrderBy(['season' => 'ASC'])]
private Collection $seasonalFinances;
#[ORM\OneToMany(mappedBy: 'room', targetEntity: Accounting::class, orphanRemoval: true)]
private Collection $accountings;
#[ORM\OneToMany(mappedBy: 'room', targetEntity: RoomUser::class, orphanRemoval: true)]
private Collection $roomUsers;
#[ORM\OneToMany(mappedBy: 'room', targetEntity: Fee::class)]
private Collection $fees;
public function __construct(Hotel $hotel)
{
$this->bookings = new ArrayCollection();
$this->seasonalFinances = new ArrayCollection();
$this->accountings = new ArrayCollection();
$this->roomUsers = new ArrayCollection();
$this->setHotel($hotel);
$this->fees = new ArrayCollection();
}
public function __toString() {
return $this->name;
}
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 getColor(): ?string
{
return $this->color;
}
public function setColor(?string $color): self
{
$this->color = $color;
return $this;
}
public function getBedsId(): ?string
{
return $this->bedsId;
}
public function setBedsId(?string $bedsId): self
{
$this->bedsId = $bedsId;
return $this;
}
public function getHotel(): ?Hotel
{
return $this->hotel;
}
public function setHotel(?Hotel $hotel): self
{
$this->hotel = $hotel;
return $this;
}
/**
* @return Collection<int, Booking>
*/
public function getBookings(): Collection
{
return $this->bookings;
}
public function addBooking(Booking $booking): self
{
if (!$this->bookings->contains($booking)) {
$this->bookings->add($booking);
$booking->setRoom($this);
}
return $this;
}
public function removeBooking(Booking $booking): self
{
if ($this->bookings->removeElement($booking)) {
// set the owning side to null (unless already changed)
if ($booking->getRoom() === $this) {
$booking->setRoom(null);
}
}
return $this;
}
/**
* @return Collection<int, Accounting>
*/
public function getAccountings(): Collection
{
return $this->accountings;
}
public function addAccounting(Accounting $accounting): self
{
if (!$this->accountings->contains($accounting)) {
$this->accountings->add($accounting);
$accounting->setRoom($this);
}
return $this;
}
public function removeAccounting(Accounting $accounting): self
{
if ($this->accountings->removeElement($accounting)) {
// set the owning side to null (unless already changed)
if ($accounting->getRoom() === $this) {
$accounting->setRoom(null);
}
}
return $this;
}
/**
* @return Collection<int, RoomUser>
*/
public function getRoomUsers(): Collection
{
return $this->roomUsers;
}
public function addRoomUser(RoomUser $roomUser): self
{
if (!$this->roomUsers->contains($roomUser)) {
$this->roomUsers->add($roomUser);
$roomUser->setRoom($this);
}
return $this;
}
public function removeRoomUser(RoomUser $roomUser): self
{
if ($this->roomUsers->removeElement($roomUser)) {
// set the owning side to null (unless already changed)
if ($roomUser->getRoom() === $this) {
$roomUser->setRoom(null);
}
}
return $this;
}
/**
* @return Collection<int, Fee>
*/
public function getFees(): Collection
{
return $this->fees;
}
public function addFee(Fee $fee): self
{
if (!$this->fees->contains($fee)) {
$this->fees->add($fee);
$fee->setRoom($this);
}
return $this;
}
public function removeFee(Fee $fee): self
{
if ($this->fees->removeElement($fee)) {
// set the owning side to null (unless already changed)
if ($fee->getRoom() === $this) {
$fee->setRoom(null);
}
}
return $this;
}
/**
* @return Collection<int, SeasonalFinance>
*/
public function getSeasonalFinances(): Collection
{
return $this->seasonalFinances;
}
public function addSeasonalFinance(SeasonalFinance $seasonalFinance): self
{
if (!$this->seasonalFinances->contains($seasonalFinance)) {
$this->seasonalFinances->add($seasonalFinance);
$seasonalFinance->setRoom($this);
}
return $this;
}
public function removeSeasonalFinance(SeasonalFinance $seasonalFinance): self
{
if ($this->seasonalFinances->removeElement($seasonalFinance)) {
// set the owning side to null (unless already changed)
if ($seasonalFinance->getRoom() === $this) {
$seasonalFinance->setRoom(null);
}
}
return $this;
}
}