src/Entity/LotConfiguration.php line 16

  1. <?php
  2. namespace App\Entity;
  3. use App\Kimia;
  4. use App\Repository\LotConfigurationRepository;
  5. use App\Trait\DateTrait;
  6. use DateTimeImmutable;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\DBAL\Types\Types;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. #[ORM\Entity(repositoryClassLotConfigurationRepository::class)]
  13. class LotConfiguration
  14. {
  15.     use DateTrait;
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column]
  19.     private ?int $id null;
  20.     #[ORM\Column(length255)]
  21.     private ?string $name null;
  22.     #[ORM\Column(nullabletrue)]
  23.     private ?int $sizeWidth null;
  24.     #[ORM\Column(nullabletrue)]
  25.     private ?int $sizeHeight null;
  26.     #[ORM\Column(nullabletrue)]
  27.     private ?int $qrSize null;
  28.     #[ORM\Column(nullabletrue)]
  29.     private ?int $qrPositionX null;
  30.     #[ORM\Column(nullabletrue)]
  31.     private ?int $qrPositionY null;
  32.     #[ORM\ManyToOne(cascade: ["persist""remove"])]
  33.     #[ORM\JoinColumn(nullablefalse)]
  34.     private ?Attachment $attachment null;
  35.     #[ORM\Column]
  36.     private ?int $volume null;
  37.     #[ORM\Column(typeTypes::SMALLINToptions: ["default" => Kimia::LOT_TICKET])]
  38.     private ?int $type null;
  39.     #[ORM\OneToMany(mappedBy'configuration'targetEntityLot::class)]
  40.     private Collection $lots;
  41.     #[ORM\ManyToOne]
  42.     #[ORM\JoinColumn(nullablefalse)]
  43.     private ?Establishment $establishment null;
  44.     #[ORM\ManyToOne(cascade: ["persist""remove"])]
  45.     private ?Attachment $qrAttachment null;
  46.     #[ORM\ManyToOne]
  47.     #[ORM\JoinColumn(nullabletrue)]
  48.     private ?Article $article null;
  49.     #[ORM\Column(options: ["default" => false])]
  50.     private ?bool $showName false;
  51.     #[ORM\Column(nullabletrue)]
  52.     private ?int $nameSize null;
  53.     #[ORM\Column(nullabletrue)]
  54.     private ?int $namePositionX null;
  55.     #[ORM\Column(nullabletrue)]
  56.     private ?int $namePositionY null;
  57.     public function __construct()
  58.     {
  59.         if (is_null($this->createdAt)) $this->createdAt = new DateTimeImmutable();
  60.         $this->updatedAt = new DateTimeImmutable();
  61.         $this->lots = new ArrayCollection();
  62.     }
  63.     public function getId(): ?int
  64.     {
  65.         return $this->id;
  66.     }
  67.     public function getName(): ?string
  68.     {
  69.         return $this->name;
  70.     }
  71.     public function setName(string $name): self
  72.     {
  73.         $this->name $name;
  74.         return $this;
  75.     }
  76.     public function getSizeWidth(): ?int
  77.     {
  78.         return $this->sizeWidth;
  79.     }
  80.     public function setSizeWidth(int $sizeWidth): self
  81.     {
  82.         $this->sizeWidth $sizeWidth;
  83.         return $this;
  84.     }
  85.     public function getSizeHeight(): ?int
  86.     {
  87.         return $this->sizeHeight;
  88.     }
  89.     public function setSizeHeight(int $sizeHeight): self
  90.     {
  91.         $this->sizeHeight $sizeHeight;
  92.         return $this;
  93.     }
  94.     public function getQrSize(): ?int
  95.     {
  96.         return $this->qrSize;
  97.     }
  98.     public function setQrSize(int $qrSize): self
  99.     {
  100.         $this->qrSize $qrSize;
  101.         return $this;
  102.     }
  103.     public function getQrPositionX(): ?int
  104.     {
  105.         return $this->qrPositionX;
  106.     }
  107.     public function setQrPositionX(int $qrPositionX): self
  108.     {
  109.         $this->qrPositionX $qrPositionX;
  110.         return $this;
  111.     }
  112.     public function getQrPositionY(): ?int
  113.     {
  114.         return $this->qrPositionY;
  115.     }
  116.     public function setQrPositionY(int $qrPositionY): self
  117.     {
  118.         $this->qrPositionY $qrPositionY;
  119.         return $this;
  120.     }
  121.     public function getAttachment(): ?Attachment
  122.     {
  123.         return $this->attachment;
  124.     }
  125.     public function setAttachment(?Attachment $attachment): self
  126.     {
  127.         $this->attachment $attachment;
  128.         return $this;
  129.     }
  130.     public function getVolume(): ?int
  131.     {
  132.         return $this->volume;
  133.     }
  134.     public function setVolume(int $volume): self
  135.     {
  136.         $this->volume $volume;
  137.         return $this;
  138.     }
  139.     public function getType(): ?int
  140.     {
  141.         return $this->type;
  142.     }
  143.     public static function getTypes(): array
  144.     {
  145.         return [
  146.             "Billet d'événément" => Kimia::LOT_TICKET,
  147.             "Invitation" => Kimia::LOT_INVITATION,
  148.             "QR Code" => Kimia::LOT_QR
  149.         ];
  150.     }
  151.     public function getTypeName(): ?string
  152.     {
  153.         return array_flip(self::getTypes())[$this->getType()];
  154.     }
  155.     public function setType(int $type): self
  156.     {
  157.         $this->type $type;
  158.         return $this;
  159.     }
  160.     /**
  161.      * @return Collection<int, Lot>
  162.      */
  163.     public function getLots(): Collection
  164.     {
  165.         return $this->lots;
  166.     }
  167.     public function addLot(Lot $lot): self
  168.     {
  169.         if (!$this->lots->contains($lot)) {
  170.             $this->lots->add($lot);
  171.             $lot->setConfiguration($this);
  172.         }
  173.         return $this;
  174.     }
  175.     public function removeLot(Lot $lot): self
  176.     {
  177.         if ($this->lots->removeElement($lot)) {
  178.             // set the owning side to null (unless already changed)
  179.             if ($lot->getConfiguration() === $this) {
  180.                 $lot->setConfiguration(null);
  181.             }
  182.         }
  183.         return $this;
  184.     }
  185.     public function countTickets(): int
  186.     {
  187.         $count 0;
  188.         foreach ($this->getLots() as $lot)
  189.             $count += $lot->getTickets()->count();
  190.         return $count;
  191.     }
  192.     public function getEstablishment(): ?Establishment
  193.     {
  194.         return $this->establishment;
  195.     }
  196.     public function setEstablishment(?Establishment $establishment): self
  197.     {
  198.         $this->establishment $establishment;
  199.         return $this;
  200.     }
  201.     public function getQrAttachment(): ?Attachment
  202.     {
  203.         return $this->qrAttachment;
  204.     }
  205.     public function setQrAttachment(?Attachment $qrAttachment): self
  206.     {
  207.         $this->qrAttachment $qrAttachment;
  208.         return $this;
  209.     }
  210.     public function getArticle(): ?Article
  211.     {
  212.         return $this->article;
  213.     }
  214.     public function setArticle(?Article $article): self
  215.     {
  216.         $this->article $article;
  217.         return $this;
  218.     }
  219.     public function __toString(): string
  220.     {
  221.         return $this->name;
  222.     }
  223.     public function isShowName(): ?bool
  224.     {
  225.         return $this->showName;
  226.     }
  227.     public function setShowName(bool $showName): static
  228.     {
  229.         $this->showName $showName;
  230.         return $this;
  231.     }
  232.     public function getNameSize(): ?int
  233.     {
  234.         return $this->nameSize;
  235.     }
  236.     public function setNameSize(?int $nameSize): static
  237.     {
  238.         $this->nameSize $nameSize;
  239.         return $this;
  240.     }
  241.     public function getNamePositionX(): ?int
  242.     {
  243.         return $this->namePositionX;
  244.     }
  245.     public function setNamePositionX(?int $namePositionX): static
  246.     {
  247.         $this->namePositionX $namePositionX;
  248.         return $this;
  249.     }
  250.     public function getNamePositionY(): ?int
  251.     {
  252.         return $this->namePositionY;
  253.     }
  254.     public function setNamePositionY(?int $namePositionY): static
  255.     {
  256.         $this->namePositionY $namePositionY;
  257.         return $this;
  258.     }
  259. }