src/Entity/Ticket.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TicketRepository;
  4. use DateTime;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. #[ORM\Entity(repositoryClassTicketRepository::class)]
  11. class Ticket
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type'integer')]
  16.     #[Groups(['paymentGroup''orderJsonData'])]
  17.     private $id;
  18.     #[ORM\Column(type'string'length255)]
  19.     #[Groups(['paymentGroup''orderJsonData'])]
  20.     private $title;
  21.     #[ORM\Column(type'integer')]
  22.     #[Groups(['paymentGroup'])]
  23.     private $maxCapacity;
  24.     #[ORM\Column(type'datetime'nullabletrue)]
  25.     private $salableFrom null;
  26.     #[ORM\Column(type'integer')]
  27.     #[Groups(['paymentGroup''orderJsonData'])]
  28.     #[Assert\GreaterThanOrEqual(value0)]
  29.     private $price;
  30.     #[ORM\ManyToOne(inversedBy'tickets')]
  31.     #[Groups(['paymentGroup'])]
  32.     private ?Event $relatedEvent null;
  33.     #[ORM\Column(length255nullabletrue)]
  34.     #[Groups(['paymentGroup''orderJsonData'])]
  35.     private ?string $axo_id null;
  36.     #[ORM\Column]
  37.     #[Groups(['paymentGroup''orderJsonData'])]
  38.     #[Assert\GreaterThanOrEqual(value0)]
  39.     #[Assert\LessThanOrEqual(value100)]
  40.     private ?int $tva 0;
  41.     #[ORM\Column(nullablefalse)]
  42.     private ?int $currentOrdersCount 0;
  43.     #[ORM\Column(length255nullabletrue)]
  44.     private ?string $description "";
  45.     #[ORM\OneToMany(mappedBy'ticket'targetEntityTicketCart::class)]
  46.     private Collection $ticketCarts;
  47.     #[ORM\OneToMany(mappedBy'toTicket'targetEntityMoveHistory::class)]
  48.     private Collection $moveHistories;
  49.     public function __construct()
  50.     {
  51.         $this->ticketCarts = new ArrayCollection();
  52.         $this->moveHistories = new ArrayCollection();
  53.         if (null === $this->salableFrom) {
  54.             $this->salableFrom = new DateTime('now');
  55.         }
  56.     }
  57.     public function getId(): ?int
  58.     {
  59.         return $this->id;
  60.     }
  61.     public function getTitle(): ?string
  62.     {
  63.         return $this->title;
  64.     }
  65.     public function setTitle(string $title): self
  66.     {
  67.         $this->title $title;
  68.         return $this;
  69.     }
  70.     public function getMaxCapacity(): ?int
  71.     {
  72.         return $this->maxCapacity;
  73.     }
  74.     public function setMaxCapacity(int $maxCapacity): self
  75.     {
  76.         $this->maxCapacity $maxCapacity;
  77.         return $this;
  78.     }
  79.     public function getSalableFrom(): ?\DateTimeInterface
  80.     {
  81.         return $this->salableFrom;
  82.     }
  83.     public function setSalableFrom(?\DateTimeInterface $salableFrom): self
  84.     {
  85.         $this->salableFrom $salableFrom;
  86.         return $this;
  87.     }
  88.     public function getPrice(): ?float
  89.     {
  90.         return $this->price/100;
  91.     }
  92.     public function setPrice(int $price): self
  93.     {
  94.         $this->price $price;
  95.         return $this;
  96.     }
  97.     public function __toString(): string
  98.     {
  99.         return $this->title;
  100.     }
  101.     public function getRelatedEvent(): ?Event
  102.     {
  103.         return $this->relatedEvent;
  104.     }
  105.     public function setRelatedEvent(?Event $relatedEvent): self
  106.     {
  107.         $this->relatedEvent $relatedEvent;
  108.         return $this;
  109.     }
  110.     public function getAxoId(): ?string
  111.     {
  112.         return $this->axo_id;
  113.     }
  114.     public function setAxoId(?string $axo_id): self
  115.     {
  116.         $this->axo_id $axo_id;
  117.         return $this;
  118.     }
  119.     public function getTva(): ?int
  120.     {
  121.         return $this->tva;
  122.     }
  123.     public function setTva(int $tva): self
  124.     {
  125.         $this->tva $tva;
  126.         return $this;
  127.     }
  128.     public function getCurrentOrdersCount(): ?int
  129.     {
  130.         return $this->currentOrdersCount;
  131.     }
  132.     public function setCurrentOrdersCount(?int $currentOrdersCount): self
  133.     {
  134.         $this->currentOrdersCount $currentOrdersCount;
  135.         return $this;
  136.     }
  137.     public function addOrdersCount(int $quantity 1): self
  138.     {
  139.         $this->currentOrdersCount $this->currentOrdersCount $quantity;
  140.         return $this;
  141.     }
  142.     public function removeOrdersCount(int $quantity 1): self
  143.     {
  144.         $this->currentOrdersCount $this->currentOrdersCount $quantity;
  145.         return $this;
  146.     }
  147.     public function getDescription(): ?string
  148.     {
  149.         return $this->description;
  150.     }
  151.     public function setDescription(?string $description): self
  152.     {
  153.         $this->description $description;
  154.         return $this;
  155.     }
  156.     public function getCalculatedPrice(): float|int
  157.     {
  158.         return (($this->price * (($this->tva 100) + 1)));
  159.     }
  160.     /**
  161.      * @return Collection<int, TicketCart>
  162.      */
  163.     public function getTicketCarts(): Collection
  164.     {
  165.         return $this->ticketCarts;
  166.     }
  167.     public function addTicketCart(TicketCart $ticketCart): self
  168.     {
  169.         if (!$this->ticketCarts->contains($ticketCart)) {
  170.             $this->ticketCarts->add($ticketCart);
  171.             $ticketCart->setTicket($this);
  172.         }
  173.         return $this;
  174.     }
  175.     public function removeTicketCart(TicketCart $ticketCart): self
  176.     {
  177.         if ($this->ticketCarts->removeElement($ticketCart)) {
  178.             // set the owning side to null (unless already changed)
  179.             if ($ticketCart->getTicket() === $this) {
  180.                 $ticketCart->setTicket(null);
  181.             }
  182.         }
  183.         return $this;
  184.     }
  185.     /**
  186.      * @return Collection<int, MoveHistory>
  187.      */
  188.     public function getMoveHistories(): Collection
  189.     {
  190.         return $this->moveHistories;
  191.     }
  192.     public function addMoveHistory(MoveHistory $moveHistory): self
  193.     {
  194.         if (!$this->moveHistories->contains($moveHistory)) {
  195.             $this->moveHistories->add($moveHistory);
  196.             $moveHistory->setToTicket($this);
  197.         }
  198.         return $this;
  199.     }
  200.     public function removeMoveHistory(MoveHistory $moveHistory): self
  201.     {
  202.         if ($this->moveHistories->removeElement($moveHistory)) {
  203.             // set the owning side to null (unless already changed)
  204.             if ($moveHistory->getToTicket() === $this) {
  205.                 $moveHistory->setToTicket(null);
  206.             }
  207.         }
  208.         return $this;
  209.     }
  210. }