Compare commits
3
Commits
7b6d1408f8
...
528d1a39ab
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
528d1a39ab | ||
|
|
4f451c2f75 | ||
|
|
86abb7222e |
@@ -0,0 +1,86 @@
|
||||
# SomniaRooms - API Endpoints and Objects
|
||||
|
||||
En este documento se indican los endpoints disponibles en la API de SomniaRooms, así como los mensajes de petición y respuesta en cada caso. (Vamos, un Swagger pero escrito a mano.)
|
||||
|
||||
## Config (`api/config`)
|
||||
|
||||
Permite al cliente obtener las variables de configuración del sistema. Ver más sobre las [variables de configuración](config-vars.md) en la documentación.
|
||||
|
||||
**TODO**
|
||||
|
||||
|
||||
## Room Category (`api/room/category`)
|
||||
|
||||
Estos endpoints permiten obtener la información de las categorias del sistema.
|
||||
|
||||
**TODO**
|
||||
|
||||
|
||||
## Search (`api/search`)
|
||||
|
||||
Conjunto de Endpoints para consultar el estado de las habitaciones.
|
||||
|
||||
|
||||
## Reservas (`api/booking`)
|
||||
|
||||
Endpoint para la gestión y consulta de las reservas.
|
||||
|
||||
### `api/booking/details`
|
||||
Permite obtener el detalle de una reserva.
|
||||
|
||||
Es necesario enviar la información de la reserva a consultar.
|
||||
|
||||
**Request (JSON):**
|
||||
```json
|
||||
{
|
||||
"refNumber": "2024001",
|
||||
"email": "[email protected]"
|
||||
}
|
||||
```
|
||||
|
||||
Se debe incluir el número de referencia de la reserva y el correo electrónico asociado.
|
||||
|
||||
**Response (JSON):**
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
### `api/booking/create`
|
||||
|
||||
Endpoint para crear nuevas reservas.
|
||||
|
||||
Se enviarán los datos de la reserva con el siguiente formato:
|
||||
|
||||
**Request (JSON)_**
|
||||
```json
|
||||
{
|
||||
"arrivalDate": "20240510",
|
||||
"departureDate": "20240514",
|
||||
"customerDetails": {
|
||||
"name": "Juan",
|
||||
"surname": "Perez",
|
||||
"email": "[email protected]",
|
||||
"phoneNumber": "12345678"
|
||||
},
|
||||
"rooms": [
|
||||
{
|
||||
"roomCategory": 1,
|
||||
"guestNumber": 2,
|
||||
"amount": 1
|
||||
},
|
||||
{
|
||||
"roomCategory": 1,
|
||||
"guestNumber": 3,
|
||||
"amount": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Si la reserva es correcta se devolverá el número de referencia de la reserva:
|
||||
```json
|
||||
{
|
||||
"refNumber": "2024001",
|
||||
"email": "[email protected]",
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20240508180113 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE SEQUENCE booking_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE SEQUENCE booking_customer_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE SEQUENCE booking_room_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE TABLE booking (id INT NOT NULL, arrival_date DATE NOT NULL, departure_date DATE NOT NULL, booking_time TIMESTAMP(0) WITH TIME ZONE NOT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('CREATE TABLE booking_customer (id INT NOT NULL, booking_id INT NOT NULL, name VARCHAR(64) NOT NULL, surname VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, phone_number VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('CREATE UNIQUE INDEX UNIQ_BA0D10843301C60 ON booking_customer (booking_id)');
|
||||
$this->addSql('CREATE TABLE booking_room (id INT NOT NULL, booking_id INT NOT NULL, room_category_id INT NOT NULL, guest_number INT NOT NULL, room_price INT NOT NULL, amount INT NOT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('CREATE INDEX IDX_6A0E73D53301C60 ON booking_room (booking_id)');
|
||||
$this->addSql('CREATE INDEX IDX_6A0E73D567333DD ON booking_room (room_category_id)');
|
||||
$this->addSql('ALTER TABLE booking_customer ADD CONSTRAINT FK_BA0D10843301C60 FOREIGN KEY (booking_id) REFERENCES booking (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE booking_room ADD CONSTRAINT FK_6A0E73D53301C60 FOREIGN KEY (booking_id) REFERENCES booking (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE booking_room ADD CONSTRAINT FK_6A0E73D567333DD FOREIGN KEY (room_category_id) REFERENCES room_category (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE SCHEMA public');
|
||||
$this->addSql('DROP SEQUENCE booking_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE booking_customer_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE booking_room_id_seq CASCADE');
|
||||
$this->addSql('ALTER TABLE booking_customer DROP CONSTRAINT FK_BA0D10843301C60');
|
||||
$this->addSql('ALTER TABLE booking_room DROP CONSTRAINT FK_6A0E73D53301C60');
|
||||
$this->addSql('ALTER TABLE booking_room DROP CONSTRAINT FK_6A0E73D567333DD');
|
||||
$this->addSql('DROP TABLE booking');
|
||||
$this->addSql('DROP TABLE booking_customer');
|
||||
$this->addSql('DROP TABLE booking_room');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20240508180617 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE booking ADD ref_number VARCHAR(20) NOT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE SCHEMA public');
|
||||
$this->addSql('ALTER TABLE booking DROP ref_number');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Controller\Admin\BookingCustomerCrudController;
|
||||
use App\Entity\Booking;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\CollectionField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\DateField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||
|
||||
class BookingCrudController extends AbstractCrudController
|
||||
{
|
||||
public static function getEntityFqcn(): string
|
||||
{
|
||||
return Booking::class;
|
||||
}
|
||||
|
||||
public function configureFields(string $pageName): iterable
|
||||
{
|
||||
$fieldRefNumber = TextField::new ('refNumber');
|
||||
$fieldBookingTime = DateTimeField::new ('BookingTime');
|
||||
if ($pageName == Crud::PAGE_EDIT) {
|
||||
$fieldRefNumber->setDisabled(true);
|
||||
$fieldBookingTime->setDisabled(true);
|
||||
}
|
||||
|
||||
yield FormField::addFieldset('Booking details');
|
||||
yield $fieldRefNumber;
|
||||
yield $fieldBookingTime;
|
||||
|
||||
yield DateField::new ('ArrivalDate');
|
||||
yield DateField::new ('DepartureDate');
|
||||
|
||||
yield AssociationField::new ('bookingCustomer')->renderAsEmbeddedForm(BookingCustomerCrudController::class);
|
||||
yield CollectionField::new ('bookingRooms')->useEntryCrudForm();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Entity\BookingCustomer;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||
|
||||
class BookingCustomerCrudController extends AbstractCrudController
|
||||
{
|
||||
public static function getEntityFqcn(): string
|
||||
{
|
||||
return BookingCustomer::class;
|
||||
}
|
||||
|
||||
public function configureFields(string $pageName): iterable
|
||||
{
|
||||
yield TextField::new('Name');
|
||||
yield TextField::new('Surname');
|
||||
yield TextField::new('Email');
|
||||
yield TextField::new('PhoneNumber');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Controller\Admin\RoomCategoryCrudController;
|
||||
use App\Entity\BookingRoom;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\MoneyField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
|
||||
|
||||
class BookingRoomCrudController extends AbstractCrudController
|
||||
{
|
||||
public static function getEntityFqcn(): string
|
||||
{
|
||||
return BookingRoom::class;
|
||||
}
|
||||
|
||||
public function configureFields(string $pageName): iterable
|
||||
{
|
||||
yield AssociationField::new ('RoomCategory')->setCrudController(RoomCategoryCrudController::class);
|
||||
yield NumberField::new ('GuestNumber');
|
||||
yield MoneyField::new ('RoomPrice')->setCurrency("EUR");
|
||||
yield NumberField::new ('Amount');
|
||||
}
|
||||
}
|
||||
@@ -2,20 +2,18 @@
|
||||
|
||||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Entity\Booking;
|
||||
use App\Entity\ConfigVariable;
|
||||
use App\Entity\FareTable;
|
||||
use App\Entity\RoomCategory;
|
||||
use App\Entity\RoomFare;
|
||||
use App\Entity\User;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
use App\Entity\RoomCategory;
|
||||
use App\Entity\RoomAvailability;
|
||||
use App\Entity\FareTable;
|
||||
use App\Entity\RoomFare;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Entity\ConfigVariable;
|
||||
|
||||
class SomniaDashboardController extends AbstractDashboardController
|
||||
{
|
||||
#[Route('/admin', name: 'admin')]
|
||||
@@ -34,6 +32,9 @@ class SomniaDashboardController extends AbstractDashboardController
|
||||
{
|
||||
yield MenuItem::linkToDashboard('Dashboard', 'fa fa-home');
|
||||
|
||||
yield MenuItem::Section('Booking Management');
|
||||
yield MenuItem::linkToCrud('Bookings', 'fas fa-door-open', Booking::class);
|
||||
|
||||
yield MenuItem::Section('Room Management');
|
||||
yield MenuItem::linkToCrud('Category', 'fas fa-door-open', RoomCategory::class);
|
||||
yield MenuItem::linkToRoute('Room Availability', 'fas fa-calendar-check', 'admin_roomAvailability');
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Booking;
|
||||
use App\Entity\BookingCustomer;
|
||||
use App\Entity\BookingRoom;
|
||||
use App\Repository\BookingRepository;
|
||||
use App\Repository\RoomCategoryRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
class BookingController extends AbstractController
|
||||
{
|
||||
#[Route('/api/booking/details', name: 'app_booking_details')]
|
||||
public function getBookingDetails(Request $request, BookingRepository $repoBooking): JsonResponse
|
||||
{
|
||||
$payload = $request->toArray();
|
||||
if (\is_null($payload)) {
|
||||
throw new \Exception('Invalid Payload', 400);
|
||||
}
|
||||
|
||||
$refNumber = $payload["refNumber"];
|
||||
$customerEmail = $payload["email"];
|
||||
|
||||
$bookingList = $repoBooking->findBy(["refNumber" => $refNumber]);
|
||||
if (\is_null($bookingList) || \count($bookingList) == 0) {
|
||||
throw new HttpException(404, 'Invalid Booking');
|
||||
}
|
||||
|
||||
$customerBooking = $bookingList[0];
|
||||
if ($customerBooking->getBookingCustomer()->getEmail() != $customerEmail) {
|
||||
throw new HttpException(404, 'Invalid Booking');
|
||||
}
|
||||
|
||||
return $this->json($customerBooking);
|
||||
}
|
||||
|
||||
#[Route('/api/booking/create', name: 'app_booking_create')]
|
||||
public function newBooking(Request $request, BookingRepository $repoBooking, EntityManagerInterface $entityManager, RoomCategoryRepository $repoCat): JsonResponse
|
||||
{
|
||||
$payload = $request->toArray();
|
||||
if (\is_null($payload)) {
|
||||
throw new \Exception('Invalid Payload', 400);
|
||||
}
|
||||
|
||||
$booking = new Booking();
|
||||
try {
|
||||
$reqArrivalDate = $payload["arrivalDate"];
|
||||
$reqDepartureDate = $payload["departureDate"];
|
||||
|
||||
$arrivalDate = new \DateTime($reqArrivalDate);
|
||||
$departureDate = new \DateTime($reqDepartureDate);
|
||||
|
||||
if ($arrivalDate >= $departureDate) {
|
||||
throw new HttpException(400, "Arrival cant be before departure");
|
||||
}
|
||||
|
||||
$entityManager->beginTransaction();
|
||||
|
||||
$currentTime = new \DateTime();
|
||||
|
||||
// Create booking from request data.
|
||||
//$booking = new Booking();
|
||||
$booking->setBookingTime($currentTime);
|
||||
$booking->setArrivalDate($arrivalDate);
|
||||
$booking->setDepartureDate($departureDate);
|
||||
$booking->setRefNumber($currentTime->format("Y") . "001");
|
||||
|
||||
$entityManager->persist($booking);
|
||||
|
||||
// Create booking customer.
|
||||
$reqCustomer = $payload["customerDetails"];
|
||||
$bookingCustomer = new BookingCustomer();
|
||||
$bookingCustomer->setName($reqCustomer["name"]);
|
||||
$bookingCustomer->setSurname($reqCustomer["surname"]);
|
||||
$bookingCustomer->setEmail($reqCustomer["email"]);
|
||||
$bookingCustomer->setPhoneNumber($reqCustomer["phoneNumber"]);
|
||||
$bookingCustomer->setBooking($booking);
|
||||
|
||||
$entityManager->persist($bookingCustomer);
|
||||
|
||||
$reqRoomList = $payload["rooms"];
|
||||
if (\count($reqRoomList) == 0) {
|
||||
throw new HttpException(400, "Se debe indicar al menos una habitación");
|
||||
}
|
||||
|
||||
foreach ($reqRoomList as $roomItem) {
|
||||
$room = new BookingRoom();
|
||||
$room->setBooking($booking);
|
||||
|
||||
//Get Room category.
|
||||
$roomCategory = $repoCat->find($roomItem["roomCategory"]);
|
||||
if($roomCategory == null) {
|
||||
throw new HttpException(400, "La RoomCategory no es válida.");
|
||||
}
|
||||
|
||||
$room->setRoomCategory($roomCategory);
|
||||
$room->setGuestNumber($roomItem["guestNumber"]);
|
||||
$room->setAmount($roomItem["amount"]);
|
||||
$room->setRoomPrice(5000);
|
||||
|
||||
$entityManager->persist($room);
|
||||
}
|
||||
|
||||
$entityManager->commit();
|
||||
$entityManager->flush();
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
$entityManager->rollback();
|
||||
throw $th;
|
||||
}
|
||||
|
||||
$results = ["refNumber" => $booking->getRefNumber()];
|
||||
|
||||
return $this->json($results);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
<?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, cascade: ['persist'])]
|
||||
private Collection $bookingRooms;
|
||||
|
||||
#[ORM\Column(length: 20)]
|
||||
private ?string $refNumber = null;
|
||||
|
||||
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->getBooking() !== $this) {
|
||||
$bookingCustomer->setBooking($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->setBooking($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->getBooking() === $this) {
|
||||
$bookingRoom->setBooking(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRefNumber(): ?string
|
||||
{
|
||||
return $this->refNumber;
|
||||
}
|
||||
|
||||
public function setRefNumber(string $refNumber): static
|
||||
{
|
||||
$this->refNumber = $refNumber;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
function __toString(): string
|
||||
{
|
||||
return $this->getRefNumber();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\BookingCustomerRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\Ignore;
|
||||
|
||||
#[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")]
|
||||
#[Ignore]
|
||||
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;
|
||||
}
|
||||
|
||||
#[Ignore]
|
||||
public function getBooking(): ?Booking
|
||||
{
|
||||
return $this->Booking;
|
||||
}
|
||||
|
||||
#[Ignore]
|
||||
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;
|
||||
}
|
||||
|
||||
function __toString(): string
|
||||
{
|
||||
return $this->getName() . " " . $this->getSurname();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\BookingRoomRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\Ignore;
|
||||
|
||||
#[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")]
|
||||
#[Ignore]
|
||||
private ?Booking $Booking = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[Ignore]
|
||||
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;
|
||||
}
|
||||
|
||||
#[Ignore]
|
||||
public function getBooking(): ?Booking
|
||||
{
|
||||
return $this->Booking;
|
||||
}
|
||||
|
||||
#[Ignore]
|
||||
public function setBooking(?Booking $Booking): static
|
||||
{
|
||||
$this->Booking = $Booking;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
#[Ignore]
|
||||
public function getRoomCategory(): ?RoomCategory
|
||||
{
|
||||
return $this->RoomCategory;
|
||||
}
|
||||
|
||||
#[Ignore]
|
||||
public function setRoomCategory(?RoomCategory $RoomCategory): static
|
||||
{
|
||||
$this->RoomCategory = $RoomCategory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRoomCategoryId(): int
|
||||
{
|
||||
return $this->getRoomCategory()->getId();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
function __toString(): string
|
||||
{
|
||||
return $this->getAmount() . " " . $this->getRoomCategory()->getName() . " - " . $this->getGuestNumber() . " Guests";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\BookingCustomer;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<BookingCustomer>
|
||||
*
|
||||
* @method BookingCustomer|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method BookingCustomer|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method BookingCustomer[] findAll()
|
||||
* @method BookingCustomer[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class BookingCustomerRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, BookingCustomer::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return BookingCustomer[] Returns an array of BookingCustomer objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('b')
|
||||
// ->andWhere('b.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('b.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?BookingCustomer
|
||||
// {
|
||||
// return $this->createQueryBuilder('b')
|
||||
// ->andWhere('b.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Booking;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Booking>
|
||||
*
|
||||
* @method Booking|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Booking|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Booking[] findAll()
|
||||
* @method Booking[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class BookingRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Booking::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Booking[] Returns an array of Booking objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('b')
|
||||
// ->andWhere('b.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('b.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?Booking
|
||||
// {
|
||||
// return $this->createQueryBuilder('b')
|
||||
// ->andWhere('b.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\BookingRoom;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<BookingRoom>
|
||||
*
|
||||
* @method BookingRoom|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method BookingRoom|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method BookingRoom[] findAll()
|
||||
* @method BookingRoom[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class BookingRoomRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, BookingRoom::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return BookingRoom[] Returns an array of BookingRoom objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('b')
|
||||
// ->andWhere('b.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('b.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?BookingRoom
|
||||
// {
|
||||
// return $this->createQueryBuilder('b')
|
||||
// ->andWhere('b.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user