src/Entity/Booking/Booking.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Booking;
  3. use App\Entity\Address\AddressUser;
  4. use App\Entity\Article\Service;
  5. use App\Entity\Course\Plan;
  6. use App\Entity\Payment\Payment;
  7. use App\Entity\User;
  8. use App\Repository\Booking\BookingRepository;
  9. use Doctrine\ORM\Mapping as ORM;
  10. /**
  11.  * @ORM\Entity(repositoryClass=BookingRepository::class)
  12.  * @ORM\Table(name="`booking`")
  13.  */
  14. class Booking
  15. {
  16.     public const STATE_IN_PROGRESS      'in_progress';
  17.     public const STATE_AWAITING_PAYMENT 'awaiting_payment';
  18.     public const STATE_COMPLETED        'completed';
  19.     public const STATE_FULFILLED        'fulfilled';
  20.     public const STATE_CANCELLED        'cancelled';
  21.     public const STATE_REJECTED         'rejected';
  22.     public const STATE_FAILED           'failed';
  23.     public $states = array(
  24.         self::STATE_IN_PROGRESS         => 'admin.booking.states.in_progress',
  25.         self::STATE_FULFILLED           => 'admin.booking.states.fulfilled',
  26.         self::STATE_CANCELLED           => 'admin.booking.states.cancelled',
  27.         self::STATE_REJECTED            => 'admin.booking.states.rejected',
  28.         self::STATE_FAILED              => 'admin.booking.states.failed'
  29.     );
  30.     public $checkoutStates = array(
  31.         self::STATE_IN_PROGRESS         => 'admin.booking.states.in_progress',
  32.         self::STATE_COMPLETED           => 'admin.booking.states.completed',
  33.         self::STATE_CANCELLED           => 'admin.booking.states.cancelled',
  34.         self::STATE_REJECTED            => 'admin.booking.states.rejected',
  35.     );
  36.     public $paymentStates = array(
  37.         Payment::STATE_NEW  => 'New',
  38.         Payment::STATE_AWAITING_PAYMENT  => 'Awaiting payment',
  39.         Payment::STATE_COMPLETED   => 'admin.booking.states.completed',
  40.         Payment::STATE_FAILED      => 'admin.booking.states.failed'
  41.     );
  42.     public $classes = array(
  43.         self::STATE_IN_PROGRESS         => 'warning',
  44.         self::STATE_AWAITING_PAYMENT    => 'info',
  45.         self::STATE_COMPLETED           => 'success',
  46.         self::STATE_FULFILLED           => 'primary',
  47.         self::STATE_CANCELLED           => 'default',
  48.         self::STATE_REJECTED            => 'danger',
  49.         self::STATE_FAILED              => 'danger'
  50.     );
  51.     public $paymentClasses = array(
  52.         Payment::STATE_NEW  => 'info',
  53.         Payment::STATE_AWAITING_PAYMENT  => 'warning',
  54.         Payment::STATE_COMPLETED   => 'success',
  55.         Payment::STATE_FAILED      => 'danger'
  56.     );
  57.     /**
  58.      * @ORM\Id
  59.      * @ORM\GeneratedValue
  60.      * @ORM\Column(type="integer")
  61.      */
  62.     private $id;
  63.     /**
  64.      * @ORM\Column(type="string", length=255)
  65.      */
  66.     private $number;
  67.     /**
  68.      * @ORM\Column(type="string", length=255, nullable=true)
  69.      */
  70.     private $type 'horse';
  71.     /**
  72.      * @ORM\Column(type="text", nullable=true)
  73.      */
  74.     private $notes;
  75.     /**
  76.      * @ORM\Column(type="string", length=255)
  77.      */
  78.     private $state;
  79.     /**
  80.      * @ORM\Column(type="integer", nullable=true)
  81.      */
  82.     private $duration;
  83.     /**
  84.      * @ORM\Column(type="datetime", nullable=true)
  85.      */
  86.     private $reservationDate;
  87.     /**
  88.      * @ORM\Column(type="integer")
  89.      */
  90.     private $adults 1;
  91.     /**
  92.      * @ORM\Column(type="integer")
  93.      */
  94.     private $childrens 0;
  95.     /**
  96.      * @ORM\Column(type="string", length=255)
  97.      */
  98.     private $checkoutState;
  99.     /**
  100.      * @ORM\Column(type="string", length=255)
  101.      */
  102.     private $paymentState;
  103.     /**
  104.      * @ORM\Column(type="integer")
  105.      */
  106.     private $total;
  107.     /**
  108.      * @ORM\Column(type="integer")
  109.      */
  110.     private $itemsTotal;
  111.     /**
  112.      * @ORM\Column(type="integer")
  113.      */
  114.     private $dicountsTotal;
  115.     /**
  116.      * @ORM\Column(type="integer")
  117.      */
  118.     private $taxesTotal;
  119.     /**
  120.      * @ORM\Column(type="string", length=5)
  121.      */
  122.     private $currencyCode;
  123.     /**
  124.      * @ORM\Column(type="string", length=255)
  125.      */
  126.     private $localeCode;
  127.     /**
  128.      * @ORM\Column(type="datetime", nullable=true)
  129.      */
  130.     private $checkoutCompletedAt;
  131.     /**
  132.      * @ORM\Column(type="datetime")
  133.      */
  134.     private $createdAt;
  135.     /**
  136.      * @ORM\Column(type="datetime", nullable=true)
  137.      */
  138.     private $updatedAt;
  139.     /**
  140.      * @ORM\ManyToOne(targetEntity=AddressUser::class, inversedBy="billingBookings", cascade={"persist"})
  141.      */
  142.     private $billingAddress;
  143.     /**
  144.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="bookings", cascade={"persist", "remove"})
  145.      */
  146.     private $customer;
  147.     /**
  148.      * @ORM\OneToOne(targetEntity=Payment::class, mappedBy="checkout", cascade={"persist", "remove"})
  149.      */
  150.     private $payment;
  151.     /**
  152.      * @ORM\Column(type="string", length=255)
  153.      */
  154.     private $location 'agafay';
  155.     /**
  156.      * @ORM\ManyToOne(targetEntity=Plan::class, inversedBy="bookings")
  157.      */
  158.     private $plan;
  159.     /**
  160.      * @ORM\ManyToOne(targetEntity=Service::class, inversedBy="bookings")
  161.      */
  162.     private $service;
  163.     public function __construct()
  164.     {
  165.         $this->total 0;
  166.         $this->itemsTotal 0;
  167.         $this->taxesTotal 0;
  168.         $this->dicountsTotal 0;
  169.         $this->currencyCode 'MAD';
  170.         $this->state self::STATE_IN_PROGRESS;
  171.         $this->checkoutState self::STATE_IN_PROGRESS;
  172.         $this->paymentState Payment::STATE_NEW;
  173.         $this->createdAt = new \DateTimeImmutable();
  174.         $this->updatedAt = new \DateTimeImmutable();
  175.     }
  176.     public function __toString(): string
  177.     {
  178.         return '#' $this->id;
  179.     }
  180.     public function getId(): ?int
  181.     {
  182.         return $this->id;
  183.     }
  184.     public function getNumber(): ?string
  185.     {
  186.         return $this->number;
  187.     }
  188.     public function setNumber(string $number): self
  189.     {
  190.         $this->number $number;
  191.         return $this;
  192.     }
  193.     public function getType(): ?string
  194.     {
  195.         return $this->type;
  196.     }
  197.     public function setType(?string $type): self
  198.     {
  199.         $this->type $type;
  200.         return $this;
  201.     }
  202.     public function getNotes(): ?string
  203.     {
  204.         return $this->notes;
  205.     }
  206.     public function setNotes(?string $notes): self
  207.     {
  208.         $this->notes $notes;
  209.         return $this;
  210.     }
  211.     public function getState(): ?string
  212.     {
  213.         return $this->state;
  214.     }
  215.     public function setState(string $state): self
  216.     {
  217.         $this->state $state;
  218.         return $this;
  219.     }
  220.     public function getDuration(): ?int
  221.     {
  222.         return $this->duration;
  223.     }
  224.     public function setDuration(?int $duration): self
  225.     {
  226.         $this->duration $duration;
  227.         return $this;
  228.     }
  229.     public function getReservationDate(): ?\DateTimeInterface
  230.     {
  231.         return $this->reservationDate;
  232.     }
  233.     public function setReservationDate(?\DateTimeInterface $reservationDate): self
  234.     {
  235.         $this->reservationDate $reservationDate;
  236.         return $this;
  237.     }
  238.     public function getAdults(): ?int
  239.     {
  240.         return $this->adults;
  241.     }
  242.     public function setAdults(int $adults): self
  243.     {
  244.         $this->adults $adults;
  245.         return $this;
  246.     }
  247.     public function getChildrens(): ?int
  248.     {
  249.         return $this->childrens;
  250.     }
  251.     public function setChildrens(int $childrens): self
  252.     {
  253.         $this->childrens $childrens;
  254.         return $this;
  255.     }
  256.     public function getCheckoutState(): ?string
  257.     {
  258.         return $this->checkoutState;
  259.     }
  260.     public function setCheckoutState(string $checkoutState): self
  261.     {
  262.         $this->checkoutState $checkoutState;
  263.         return $this;
  264.     }
  265.     public function getPaymentState(): ?string
  266.     {
  267.         return $this->paymentState;
  268.     }
  269.     public function setPaymentState(string $paymentState): self
  270.     {
  271.         $this->paymentState $paymentState;
  272.         return $this;
  273.     }
  274.     public function getTotal(): ?int
  275.     {
  276.         return $this->total;
  277.     }
  278.     public function setTotal(int $total): self
  279.     {
  280.         $this->total $total;
  281.         return $this;
  282.     }
  283.     public function getItemsTotal(): ?int
  284.     {
  285.         return $this->itemsTotal;
  286.     }
  287.     public function setItemsTotal(int $itemsTotal): self
  288.     {
  289.         $this->itemsTotal $itemsTotal;
  290.         return $this;
  291.     }
  292.     public function getDicountsTotal(): ?int
  293.     {
  294.         return $this->dicountsTotal;
  295.     }
  296.     public function setDicountsTotal(int $dicountsTotal): self
  297.     {
  298.         $this->dicountsTotal $dicountsTotal;
  299.         return $this;
  300.     }
  301.     public function getTaxesTotal(): int
  302.     {
  303.         return $this->taxesTotal;
  304.     }
  305.     public function setTaxesTotal(int $taxesTotal): self
  306.     {
  307.         $this->taxesTotal $taxesTotal;
  308.         return $this;
  309.     }
  310.     public function getCurrencyCode(): ?string
  311.     {
  312.         return $this->currencyCode;
  313.     }
  314.     public function setCurrencyCode(string $currencyCode): self
  315.     {
  316.         $this->currencyCode $currencyCode;
  317.         return $this;
  318.     }
  319.     public function getLocaleCode(): ?string
  320.     {
  321.         return $this->localeCode;
  322.     }
  323.     public function setLocaleCode(string $localeCode): self
  324.     {
  325.         $this->localeCode $localeCode;
  326.         return $this;
  327.     }
  328.     public function getCheckoutCompletedAt(): ?\DateTimeInterface
  329.     {
  330.         return $this->checkoutCompletedAt;
  331.     }
  332.     public function setCheckoutCompletedAt(?\DateTimeInterface $checkoutCompletedAt): self
  333.     {
  334.         $this->checkoutCompletedAt $checkoutCompletedAt;
  335.         return $this;
  336.     }
  337.     public function getCreatedAt(): ?\DateTimeInterface
  338.     {
  339.         return $this->createdAt;
  340.     }
  341.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  342.     {
  343.         $this->createdAt $createdAt;
  344.         return $this;
  345.     }
  346.     public function getUpdatedAt(): ?\DateTimeInterface
  347.     {
  348.         return $this->updatedAt;
  349.     }
  350.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  351.     {
  352.         $this->updatedAt $updatedAt;
  353.         return $this;
  354.     }
  355.     public function getBillingAddress(): ?AddressUser
  356.     {
  357.         return $this->billingAddress;
  358.     }
  359.     public function setBillingAddress(?AddressUser $billingAddress): self
  360.     {
  361.         $this->billingAddress $billingAddress;
  362.         return $this;
  363.     }
  364.     public function getCustomer(): ?User
  365.     {
  366.         return $this->customer;
  367.     }
  368.     public function setCustomer(?User $customer): self
  369.     {
  370.         $this->customer $customer;
  371.         return $this;
  372.     }
  373.     public function getStatus($state)
  374.     {
  375.         return $this->states[$state] ?? $this->checkoutStates[$state];
  376.     }
  377.     public function getPaymentStatus($state)
  378.     {
  379.         return $this->paymentStates[$state];
  380.     }
  381.     public function getPayment(): ?Payment
  382.     {
  383.         return $this->payment;
  384.     }
  385.     public function setPayment(?Payment $payment): self
  386.     {
  387.         // unset the owning side of the relation if necessary
  388.         if ($payment === null && $this->payment !== null) {
  389.             $this->payment->setCheckout(null);
  390.         }
  391.         // set the owning side of the relation if necessary
  392.         if ($payment !== null && $payment->getCheckout() !== $this) {
  393.             $payment->setCheckout($this);
  394.         }
  395.         $this->payment $payment;
  396.         return $this;
  397.     }
  398.     public function getLocation(): ?string
  399.     {
  400.         return $this->location;
  401.     }
  402.     public function setLocation(string $location): self
  403.     {
  404.         $this->location $location;
  405.         return $this;
  406.     }
  407.     public function getPlan(): ?Plan
  408.     {
  409.         return $this->plan;
  410.     }
  411.     public function setPlan(?Plan $plan): self
  412.     {
  413.         $this->plan $plan;
  414.         return $this;
  415.     }
  416.     public function getService(): ?Service
  417.     {
  418.         return $this->service;
  419.     }
  420.     public function setService(?Service $service): self
  421.     {
  422.         $this->service $service;
  423.         return $this;
  424.     }
  425. }