FareTables and RoomFares - Implementación inicial

Creación del modelo y pantallas base para administración.
This commit is contained in:
2024-04-29 23:14:28 +02:00
parent 8e7bad7771
commit 7ec989a76a
9 changed files with 427 additions and 1 deletions
+132
View File
@@ -0,0 +1,132 @@
<?php
namespace App\Entity;
use App\Repository\FareTableRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: FareTableRepository::class)]
class FareTable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: false, onDelete: "CASCADE")]
private ?RoomCategory $roomCategory = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
private ?\DateTimeInterface $startDate = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $endDate = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $comment = null;
/**
* @var Collection<int, RoomFare>
*/
#[ORM\OneToMany(targetEntity: RoomFare::class, mappedBy: 'fareTable', orphanRemoval: true)]
private Collection $roomFares;
public function __construct()
{
$this->roomFares = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getRoomCategory(): ?RoomCategory
{
return $this->roomCategory;
}
public function setRoomCategory(?RoomCategory $roomCategory): static
{
$this->roomCategory = $roomCategory;
return $this;
}
public function getStartDate(): ?\DateTimeInterface
{
return $this->startDate;
}
public function setStartDate(\DateTimeInterface $startDate): static
{
$this->startDate = $startDate;
return $this;
}
public function getEndDate(): ?\DateTimeInterface
{
return $this->endDate;
}
public function setEndDate(?\DateTimeInterface $endDate): static
{
$this->endDate = $endDate;
return $this;
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(?string $comment): static
{
$this->comment = $comment;
return $this;
}
/**
* @return Collection<int, RoomFare>
*/
public function getRoomFares(): Collection
{
return $this->roomFares;
}
public function addRoomFare(RoomFare $roomFare): static
{
if (!$this->roomFares->contains($roomFare)) {
$this->roomFares->add($roomFare);
$roomFare->setFareTable($this);
}
return $this;
}
public function removeRoomFare(RoomFare $roomFare): static
{
if ($this->roomFares->removeElement($roomFare)) {
// set the owning side to null (unless already changed)
if ($roomFare->getFareTable() === $this) {
$roomFare->setFareTable(null);
}
}
return $this;
}
public function __toString() : string {
if(!\is_null($this->comment)) {
return $this->comment;
}
return $this->id;
}
}
+5 -1
View File
@@ -5,7 +5,6 @@ namespace App\Entity;
use App\Repository\RoomCategoryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Serializer\Annotation\Ignore;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
@@ -159,4 +158,9 @@ class RoomCategory
return $this;
}
public function __toString()
{
return $this->name;
}
}
+81
View File
@@ -0,0 +1,81 @@
<?php
namespace App\Entity;
use App\Repository\RoomFareRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: RoomFareRepository::class)]
class RoomFare
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'roomFares')]
#[ORM\JoinColumn(nullable: false)]
private ?FareTable $fareTable = null;
#[ORM\Column]
private ?int $guestNumber = null;
#[ORM\Column]
private ?int $fareAmount = null;
#[ORM\Column(length: 2, nullable: true)]
private ?string $dayType = null;
public function getId(): ?int
{
return $this->id;
}
public function getFareTable(): ?FareTable
{
return $this->fareTable;
}
public function setFareTable(?FareTable $fareTable): static
{
$this->fareTable = $fareTable;
return $this;
}
public function getGuestNumber(): ?int
{
return $this->guestNumber;
}
public function setGuestNumber(int $guestNumber): static
{
$this->guestNumber = $guestNumber;
return $this;
}
public function getFareAmount(): ?int
{
return $this->fareAmount;
}
public function setFareAmount(int $fareAmount): static
{
$this->fareAmount = $fareAmount;
return $this;
}
public function getDayType(): ?string
{
return $this->dayType;
}
public function setDayType(?string $dayType): static
{
$this->dayType = $dayType;
return $this;
}
}