src/Entity/MarketplaceReservation.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\MarketplaceReservationRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. /**
  8.  * @ORM\Entity(repositoryClass=MarketplaceReservationRepository::class)
  9.  */
  10. class MarketplaceReservation
  11. {
  12.     const PAYMENT_STATUS_FREE 'free';
  13.     const PAYMENT_STATUS_PENDING 'pending';
  14.     const PAYMENT_STATUS_CANCELED 'canceled';
  15.     const PAYMENT_STATUS_FAILED 'failed';
  16.     const PAYMENT_STATUS_SUCCESS 'success';
  17.     const PAYMENT_STATUS_REFUND_PENDING 'pending_refund';
  18.     const PAYMENT_STATUS_REFUND 'refund';
  19.     const STATUS_PENDING 'pending'// when the registration needs a confirmation (aka: payment most of the time)
  20.     const STATUS_PENDING_CANCELLATION 'pending_cancellation';
  21.     const STATUS_CANCELED 'canceled';
  22.     const STATUS_ACCEPTED 'accepted';
  23.     const STATUS_REFUSED 'refused';
  24.     
  25.     const STATUSES = [
  26.         self::STATUS_PENDING,
  27.         self::STATUS_ACCEPTED,
  28.         self::STATUS_PENDING_CANCELLATION,
  29.         self::STATUS_CANCELED,
  30.         self::STATUS_REFUSED,
  31.     ];
  32.     /**
  33.      * @ORM\Id
  34.      * @ORM\GeneratedValue
  35.      * @ORM\Column(type="integer")
  36.      */
  37.     private $id;
  38.     /**
  39.      * @ORM\Column(type="string", length=255, nullable=true)
  40.      */
  41.     private $fullName;
  42.     /**
  43.      * @ORM\Column(type="string", length=255, nullable=true)
  44.      */
  45.     private $firstName;
  46.     /**
  47.      * @ORM\Column(type="string", length=255, nullable=true)
  48.      */
  49.     private $lastName;
  50.     /**
  51.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="marketplaceReservations")
  52.      */
  53.     private $user;
  54.     /**
  55.      * @ORM\Column(type="string", length=255, nullable=true)
  56.      */
  57.     private $phone;
  58.     /**
  59.      * @ORM\Column(type="string", length=255, nullable=true)
  60.      */
  61.     private $adress;
  62.     /**
  63.      * @ORM\Column(type="datetime", nullable=true)
  64.      */
  65.     private $dateStart;
  66.     /**
  67.      * @ORM\Column(type="time", nullable=true)
  68.      */
  69.     private $hourStart;
  70.     /**
  71.      * @ORM\Column(type="integer", nullable=true)
  72.      */
  73.     private $family;
  74.     /**
  75.      * @ORM\ManyToOne(targetEntity=MarketplaceCategory::class, inversedBy="marketplaceReservations")
  76.      */
  77.     private $category;
  78.     /**
  79.      * @ORM\Column(type="text", nullable=true)
  80.      */
  81.     private $description;
  82.     
  83.     /**
  84.      * @ORM\Column(type="string", length=255, nullable=true)
  85.      * @Assert\Choice(choices=self::STATUSES)
  86.      */
  87.     private $status self::STATUS_PENDING;
  88.     /**
  89.      * @ORM\OneToOne(targetEntity=Event::class, inversedBy="marketplaceReservation", cascade={"persist", "remove"})
  90.      */
  91.     private $event;
  92.     /**
  93.      * @ORM\ManyToOne(targetEntity=Workshop::class, inversedBy="marketplaceReservations")
  94.      */
  95.     private $workshop;
  96.     /**
  97.      * @ORM\Column(type="float", nullable=true)
  98.      */
  99.     private $paymentAmount;
  100.     /**
  101.      * @ORM\Column(type="string", length=255, nullable=true)
  102.      */
  103.     private $payment;
  104.     /**
  105.      * @ORM\Column(type="string", length=255, nullable=true)
  106.      */
  107.     private $paymentStatus;
  108.     /**
  109.      * @ORM\Column(type="float", nullable=true)
  110.      */
  111.     private $refundAmount;
  112.     /**
  113.      * @ORM\Column(type="datetime", nullable=true)
  114.      */
  115.     private $refundDate;
  116.     /**
  117.      * @ORM\Column(type="datetime")
  118.      * @Gedmo\Timestampable(on="create")
  119.      */
  120.     private $createdAt;
  121.     /**
  122.      * @ORM\Column(type="datetime", nullable=true)
  123.      * @Gedmo\Timestampable(on="update")
  124.      */
  125.     private $updatedAt;
  126.     /**
  127.      * @ORM\Column(type="string", length=255, nullable=true)
  128.      */
  129.     private $email;
  130.     /**
  131.      * @ORM\Column(type="string", length=255, nullable=true)
  132.      */
  133.     private $zipCode;
  134.     /**
  135.      * @ORM\Column(type="string", length=255, nullable=true)
  136.      */
  137.     private $town;
  138.     public function getId(): ?int
  139.     {
  140.         return $this->id;
  141.     }
  142.     public function getFullName(): ?string
  143.     {
  144.         return $this->fullName;
  145.     }
  146.     public function setFullName(?string $fullName): self
  147.     {
  148.         $this->fullName $fullName;
  149.         return $this;
  150.     }
  151.     
  152.     public function getFirstName(): ?string
  153.     {
  154.         return $this->firstName;
  155.     }
  156.     public function setFirstName(?string $firstName): self
  157.     {
  158.         $this->firstName $firstName;
  159.         return $this;
  160.     }
  161.     public function getLastName(): ?string
  162.     {
  163.         return $this->lastName;
  164.     }
  165.     public function setLastName(?string $lastName): self
  166.     {
  167.         $this->lastName $lastName;
  168.         return $this;
  169.     }
  170.     public function getUser(): ?User
  171.     {
  172.         return $this->user;
  173.     }
  174.     public function setUser(?User $user): self
  175.     {
  176.         $this->user $user;
  177.         return $this;
  178.     }
  179.     public function getPhone(): ?string
  180.     {
  181.         return $this->phone;
  182.     }
  183.     public function setPhone(?string $phone): self
  184.     {
  185.         $this->phone $phone;
  186.         return $this;
  187.     }
  188.     public function getAdress(): ?string
  189.     {
  190.         return $this->adress;
  191.     }
  192.     public function setAdress(?string $adress): self
  193.     {
  194.         $this->adress $adress;
  195.         return $this;
  196.     }
  197.     public function getDateStart(): ?\DateTimeInterface
  198.     {
  199.         return $this->dateStart;
  200.     }
  201.     public function setDateStart(?\DateTimeInterface $dateStart): self
  202.     {
  203.         $this->dateStart $dateStart;
  204.         return $this;
  205.     }
  206.     public function getHourStart(): ?\DateTimeInterface
  207.     {
  208.         return $this->hourStart;
  209.     }
  210.     public function setHourStart(?\DateTimeInterface $hourStart): self
  211.     {
  212.         $this->hourStart $hourStart;
  213.         return $this;
  214.     }
  215.     public function getFamily(): ?int
  216.     {
  217.         return $this->family;
  218.     }
  219.     public function setFamily(?int $family): self
  220.     {
  221.         $this->family $family;
  222.         return $this;
  223.     }
  224.     public function getCategory(): ?MarketplaceCategory
  225.     {
  226.         return $this->category;
  227.     }
  228.     public function setCategory(?MarketplaceCategory $category): self
  229.     {
  230.         $this->category $category;
  231.         return $this;
  232.     }
  233.     public function getDescription(): ?string
  234.     {
  235.         return $this->description;
  236.     }
  237.     public function setDescription(?string $description): self
  238.     {
  239.         $this->description $description;
  240.         return $this;
  241.     }
  242.     public function getStatus(): ?string
  243.     {
  244.         return $this->status;
  245.     }
  246.     public function setStatus(?string $status): self
  247.     {
  248.         $this->status $status;
  249.         return $this;
  250.     }
  251.     public function getEvent(): ?Event
  252.     {
  253.         return $this->event;
  254.     }
  255.     public function setEvent(?Event $event): self
  256.     {
  257.         $this->event $event;
  258.         return $this;
  259.     }
  260.     public function getWorkshop(): ?Workshop
  261.     {
  262.         return $this->workshop;
  263.     }
  264.     public function setWorkshop(?Workshop $workshop): self
  265.     {
  266.         $this->workshop $workshop;
  267.         return $this;
  268.     }
  269.     
  270.     public function getPaymentAmount(): ?float
  271.     {
  272.         return $this->paymentAmount;
  273.     }
  274.     public function setPaymentAmount(?float $paymentAmount): self
  275.     {
  276.         $this->paymentAmount $paymentAmount;
  277.         return $this;
  278.     }
  279.     public function getPayment(): ?string
  280.     {
  281.         return $this->payment;
  282.     }
  283.     public function setPayment(?string $payment): self
  284.     {
  285.         $this->payment $payment;
  286.         return $this;
  287.     }
  288.     public function getPaymentStatus(): ?string
  289.     {
  290.         return $this->paymentStatus;
  291.     }
  292.     public function setPaymentStatus(?string $paymentStatus): self
  293.     {
  294.         $this->paymentStatus $paymentStatus;
  295.         return $this;
  296.     }
  297.     public function getRefundAmount(): ?float
  298.     {
  299.         return $this->refundAmount;
  300.     }
  301.     public function setRefundAmount(?float $refundAmount): self
  302.     {
  303.         $this->refundAmount $refundAmount;
  304.         return $this;
  305.     }
  306.     public function getRefundDate(): ?\DateTimeInterface
  307.     {
  308.         return $this->refundDate;
  309.     }
  310.     public function setRefundDate(?\DateTimeInterface $refundDate): self
  311.     {
  312.         $this->refundDate $refundDate;
  313.         return $this;
  314.     }
  315.     public function getCreatedAt(): ?\DateTimeInterface
  316.     {
  317.         return $this->createdAt;
  318.     }
  319.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  320.     {
  321.         $this->createdAt $createdAt;
  322.         return $this;
  323.     }
  324.     public function getUpdatedAt(): ?\DateTimeInterface
  325.     {
  326.         return $this->updatedAt;
  327.     }
  328.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  329.     {
  330.         $this->updatedAt $updatedAt;
  331.         return $this;
  332.     }
  333.     public function isPending(): Bool
  334.     {
  335.         return $this->status == self::STATUS_PENDING;
  336.     }
  337.     public function isAccepted(): Bool
  338.     {
  339.         return $this->status == self::STATUS_ACCEPTED;
  340.     }
  341.     public function isRefused(): Bool
  342.     {
  343.         return $this->status == self::STATUS_REFUSED;
  344.     }
  345.     public function isCanceled(): Bool
  346.     {
  347.         return $this->status == self::STATUS_CANCELED;
  348.     }
  349.     public function isPaid(): Bool
  350.     {
  351.         return (!empty($this->getPaymentAmount()) && $this->getPaymentStatus() == self::PAYMENT_STATUS_SUCCESS && !empty($this->getPayment()));
  352.     }
  353.     public function isRefund(): Bool
  354.     {
  355.         return (!empty($this->getPaymentAmount()) && $this->getPaymentStatus() == self::PAYMENT_STATUS_REFUND && !empty($this->getRefundAmount()));
  356.     }
  357.     public function getEmail(): ?string
  358.     {
  359.         return $this->email;
  360.     }
  361.     public function setEmail(?string $email): self
  362.     {
  363.         $this->email $email;
  364.         return $this;
  365.     }
  366.     public function getZipCode(): ?string
  367.     {
  368.         return $this->zipCode;
  369.     }
  370.     public function setZipCode(?string $zipCode): self
  371.     {
  372.         $this->zipCode $zipCode;
  373.         return $this;
  374.     }
  375.     public function getTown(): ?string
  376.     {
  377.         return $this->town;
  378.     }
  379.     public function setTown(?string $town): self
  380.     {
  381.         $this->town $town;
  382.         return $this;
  383.     }
  384. }