<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
/**
* @ORM\Entity(repositoryClass="App\Repository\BookingRepository")
* @ORM\Table(name="booking")
*
* @UniqueEntity(fields={"reference"}, message="This reference is already used.")
*/
class Booking
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private ?int $id = null;
/**
* @ORM\Column(type="string", length=255, unique=true, nullable=true)
* @Assert\NotBlank()
*/
private ?string $reference = null;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private \DateTime $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private \DateTime $datestart;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private ?string $duration = null;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private int $total;
/**
* @ORM\Column(type="string", nullable=true)
*/
private string $currency;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $paymentId = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $paymentType = null;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private ?string $pax = null;
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $hebergementprice = null;
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $hebergementname = null;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Payment", mappedBy="booking", cascade={"persist","remove"})
*/
private Collection $payments;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="bookings")
* @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
*/
private $customer;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Experience", inversedBy="bookings")
* @ORM\JoinColumn(name="experience_id", referencedColumnName="id")
*/
private $experience;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $status = null;
// 0. PENDING 1.CONFIRMED 3.CANCELED
public function __construct()
{
$this->createdAt = new \DateTime('now');
$this->payments = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getReference(): ?string
{
return $this->reference;
}
public function setReference(string $reference): self
{
$this->reference = $reference;
return $this;
}
public function getCreatedAt(): \DateTime
{
return $this->createdAt;
}
public function setCreatedAt(\DateTime $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getTotal(): int {
return $this->total;
}
public function setTotal(int $total): void {
$this->total = $total;
}
public function getCurrency(): string
{
return $this->currency;
}
public function setCurrency(string $currency): self
{
$this->currency = $currency;
return $this;
}
public function getPaymentId(): ?string
{
return $this->paymentId;
}
public function setPaymentId(?string $paymentId): self
{
$this->paymentId = $paymentId;
return $this;
}
public function getDatestart(): \DateTime {
return $this->datestart;
}
public function getDuration(): ?string {
return $this->duration;
}
public function getPax(): ?string {
return $this->pax;
}
public function setDatestart(\DateTime $datestart): void {
$this->datestart = $datestart;
}
public function setDuration(?string $duration): void {
$this->duration = $duration;
}
public function setPax(?string $pax): void {
$this->pax = $pax;
}
public function getHebergementprice(): ?string {
return $this->hebergementprice;
}
public function getHebergementname(): ?string {
return $this->hebergementname;
}
public function setHebergementprice(?string $hebergementprice): void {
$this->hebergementprice = $hebergementprice;
}
public function setHebergementname(?string $hebergementname): void {
$this->hebergementname = $hebergementname;
}
public function getPaymentType(): ?string {
return $this->paymentType;
}
public function setPaymentType(?string $paymentType): void {
$this->paymentType = $paymentType;
}
public function getPayments(): Collection
{
return $this->payments;
}
public function addPayment(Payment $payment): self
{
if (!$this->payments->contains($payment)) {
$this->payments->add($payment);
$payment->setBooking($this);
}
return $this;
}
public function removePayment(Payment $payment): self
{
if ($this->payments->removeElement($payment)) {
// set the owning side to null (unless already changed)
if ($payment->getBooking() === $this) {
$payment->setBooking(null);
}
}
return $this;
}
public function getCustomer() {
return $this->customer;
}
public function setCustomer($customer): void {
$this->customer = $customer;
}
public function getStatus(): ?string {
return $this->status;
}
public function setStatus(?string $status): void {
$this->status = $status;
}
public function getExperience() {
return $this->experience;
}
public function setExperience($experience): void {
$this->experience = $experience;
}
}