Bookings - Create model:
- Booking model. - BookingCustomer model. - BookingRoom
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\BookingRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: BookingRepository::class)]
|
||||
class Booking
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_MUTABLE)]
|
||||
private ?\DateTimeInterface $ArrivalDate = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_MUTABLE)]
|
||||
private ?\DateTimeInterface $DepartureDate = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIMETZ_MUTABLE)]
|
||||
private ?\DateTimeInterface $BookingTime = null;
|
||||
|
||||
#[ORM\OneToOne(mappedBy: 'Booking', cascade: ['persist', 'remove'])]
|
||||
private ?BookingCustomer $bookingCustomer = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, BookingRoom>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: BookingRoom::class, mappedBy: 'Booking', orphanRemoval: true)]
|
||||
private Collection $bookingRooms;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->bookingRooms = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getArrivalDate(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->ArrivalDate;
|
||||
}
|
||||
|
||||
public function setArrivalDate(\DateTimeInterface $ArrivalDate): static
|
||||
{
|
||||
$this->ArrivalDate = $ArrivalDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDepartureDate(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->DepartureDate;
|
||||
}
|
||||
|
||||
public function setDepartureDate(\DateTimeInterface $DepartureDate): static
|
||||
{
|
||||
$this->DepartureDate = $DepartureDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBookingTime(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->BookingTime;
|
||||
}
|
||||
|
||||
public function setBookingTime(\DateTimeInterface $BookingTime): static
|
||||
{
|
||||
$this->BookingTime = $BookingTime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBookingCustomer(): ?BookingCustomer
|
||||
{
|
||||
return $this->bookingCustomer;
|
||||
}
|
||||
|
||||
public function setBookingCustomer(BookingCustomer $bookingCustomer): static
|
||||
{
|
||||
// set the owning side of the relation if necessary
|
||||
if ($bookingCustomer->getBookingId() !== $this) {
|
||||
$bookingCustomer->setBookingId($this);
|
||||
}
|
||||
|
||||
$this->bookingCustomer = $bookingCustomer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, BookingRoom>
|
||||
*/
|
||||
public function getBookingRooms(): Collection
|
||||
{
|
||||
return $this->bookingRooms;
|
||||
}
|
||||
|
||||
public function addBookingRoom(BookingRoom $bookingRoom): static
|
||||
{
|
||||
if (!$this->bookingRooms->contains($bookingRoom)) {
|
||||
$this->bookingRooms->add($bookingRoom);
|
||||
$bookingRoom->setBookingId($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeBookingRoom(BookingRoom $bookingRoom): static
|
||||
{
|
||||
if ($this->bookingRooms->removeElement($bookingRoom)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($bookingRoom->getBookingId() === $this) {
|
||||
$bookingRoom->setBookingId(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\BookingCustomerRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: BookingCustomerRepository::class)]
|
||||
class BookingCustomer
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\OneToOne(inversedBy: 'bookingCustomer', cascade: ['persist', 'remove'])]
|
||||
#[ORM\JoinColumn(nullable: false, onDelete: "CASCADE")]
|
||||
private ?Booking $Booking = null;
|
||||
|
||||
#[ORM\Column(length: 64)]
|
||||
private ?string $Name = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $Surname = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $Email = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $PhoneNumber = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getBooking(): ?Booking
|
||||
{
|
||||
return $this->Booking;
|
||||
}
|
||||
|
||||
public function setBooking(Booking $Booking): static
|
||||
{
|
||||
$this->Booking = $Booking;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->Name;
|
||||
}
|
||||
|
||||
public function setName(string $Name): static
|
||||
{
|
||||
$this->Name = $Name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSurname(): ?string
|
||||
{
|
||||
return $this->Surname;
|
||||
}
|
||||
|
||||
public function setSurname(string $Surname): static
|
||||
{
|
||||
$this->Surname = $Surname;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEmail(): ?string
|
||||
{
|
||||
return $this->Email;
|
||||
}
|
||||
|
||||
public function setEmail(string $Email): static
|
||||
{
|
||||
$this->Email = $Email;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPhoneNumber(): ?string
|
||||
{
|
||||
return $this->PhoneNumber;
|
||||
}
|
||||
|
||||
public function setPhoneNumber(string $PhoneNumber): static
|
||||
{
|
||||
$this->PhoneNumber = $PhoneNumber;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\BookingRoomRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: BookingRoomRepository::class)]
|
||||
class BookingRoom
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'bookingRooms')]
|
||||
#[ORM\JoinColumn(nullable: false, onDelete: "CASCADE")]
|
||||
private ?Booking $Booking = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?RoomCategory $RoomCategory = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $GuestNumber = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $RoomPrice = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $Amount = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getBooking(): ?Booking
|
||||
{
|
||||
return $this->Booking;
|
||||
}
|
||||
|
||||
public function setBooking(?Booking $Booking): static
|
||||
{
|
||||
$this->Booking = $Booking;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRoomCategory(): ?RoomCategory
|
||||
{
|
||||
return $this->RoomCategory;
|
||||
}
|
||||
|
||||
public function setRoomCategoryId(?RoomCategory $RoomCategory): static
|
||||
{
|
||||
$this->RoomCategory = $RoomCategory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getGuestNumber(): ?int
|
||||
{
|
||||
return $this->GuestNumber;
|
||||
}
|
||||
|
||||
public function setGuestNumber(int $GuestNumber): static
|
||||
{
|
||||
$this->GuestNumber = $GuestNumber;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRoomPrice(): ?int
|
||||
{
|
||||
return $this->RoomPrice;
|
||||
}
|
||||
|
||||
public function setRoomPrice(int $RoomPrice): static
|
||||
{
|
||||
$this->RoomPrice = $RoomPrice;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAmount(): ?int
|
||||
{
|
||||
return $this->Amount;
|
||||
}
|
||||
|
||||
public function setAmount(int $Amount): static
|
||||
{
|
||||
$this->Amount = $Amount;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user