src/Entity/Ticket.php line 23

  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use ApiPlatform\Metadata\Get;
  6. use ApiPlatform\Metadata\GetCollection;
  7. use ApiPlatform\Metadata\Post;
  8. use App\Controller\Api\Ticket\ApiTicketCheckController;
  9. use App\Controller\Api\Ticket\ApiTicketSellController;
  10. use App\Repository\TicketRepository;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. #[ApiResource(
  14.     operations: [
  15.         new GetCollection()
  16.     ]
  17. )]
  18. #[ORM\Entity(repositoryClassTicketRepository::class)]
  19. class Ticket
  20. {
  21.     #[ORM\Id]
  22.     #[ORM\GeneratedValue]
  23.     #[ORM\Column]
  24.     #[Groups(['ticket:new'])]
  25.     private ?int $id null;
  26.     #[ORM\Column]
  27.     private ?int $number null;
  28.     #[ORM\ManyToOne(inversedBy'tickets')]
  29.     #[ORM\JoinColumn(nullablefalse)]
  30.     private ?Lot $lot null;
  31.     #[ORM\Column(options: ['default' => false])]
  32.     private ?bool $isScanned false;
  33.     #[ORM\Column(options: ['default' => false])]
  34.     private ?bool $isSell false;
  35.     #[ORM\Column(nullabletrue)]
  36.     private ?\DateTimeImmutable $scannedAt null;
  37.     #[ORM\Column(nullabletrue)]
  38.     private ?\DateTimeImmutable $sellAt null;
  39.     #[ORM\Column]
  40.     private ?int $checkNbr 0;
  41.     #[ORM\Column(length255nullabletrue)]
  42.     #[Groups(['ticket:new'])]
  43.     private ?string $serial;
  44.     #[ORM\ManyToOne]
  45.     private ?Employee $sellBy null;
  46.     #[ORM\ManyToOne]
  47.     private ?Employee $checkedBy null;
  48.     public function getId(): ?int
  49.     {
  50.         return $this->id;
  51.     }
  52.     public function getNumber(): ?int
  53.     {
  54.         return $this->number;
  55.     }
  56.     public function setNumber(int $number): self
  57.     {
  58.         $this->number $number;
  59.         return $this;
  60.     }
  61.     public function getLot(): ?Lot
  62.     {
  63.         return $this->lot;
  64.     }
  65.     public function setLot(?Lot $lot): self
  66.     {
  67.         $this->lot $lot;
  68.         return $this;
  69.     }
  70.     public function isIsScanned(): bool
  71.     {
  72.         return $this->isScanned;
  73.     }
  74.     public function setIsScanned(bool $isScanned): self
  75.     {
  76.         $this->isScanned $isScanned;
  77.         return $this;
  78.     }
  79.     public function isIsSell(): bool
  80.     {
  81.         return $this->isSell;
  82.     }
  83.     public function setIsSell(bool $isSell): self
  84.     {
  85.         $this->isSell $isSell;
  86.         return $this;
  87.     }
  88.     public function getScannedAt(): ?\DateTimeImmutable
  89.     {
  90.         return $this->scannedAt;
  91.     }
  92.     public function setScannedAt(?\DateTimeImmutable $scannedAt): self
  93.     {
  94.         $this->scannedAt $scannedAt;
  95.         return $this;
  96.     }
  97.     public function getSellAt(): ?\DateTimeImmutable
  98.     {
  99.         return $this->sellAt;
  100.     }
  101.     public function setSellAt(?\DateTimeImmutable $sellAt): self
  102.     {
  103.         $this->sellAt $sellAt;
  104.         return $this;
  105.     }
  106.     public function getCheckNbr(): ?int
  107.     {
  108.         return $this->checkNbr;
  109.     }
  110.     public function check()
  111.     {
  112.         return $this->checkNbr++;
  113.     }
  114.     public function setCheckNbr(int $checkNbr): self
  115.     {
  116.         $this->checkNbr $checkNbr;
  117.         return $this;
  118.     }
  119.     public function getSerial(): ?string
  120.     {
  121.         return $this->serial;
  122.     }
  123.     public function setSerial(?string $serial): self
  124.     {
  125.         $this->serial $serial;
  126.         return $this;
  127.     }
  128.     public function getSellBy(): ?Employee
  129.     {
  130.         return $this->sellBy;
  131.     }
  132.     public function setSellBy(?Employee $sellBy): self
  133.     {
  134.         $this->sellBy $sellBy;
  135.         return $this;
  136.     }
  137.     public function getCheckedBy(): ?Employee
  138.     {
  139.         return $this->checkedBy;
  140.     }
  141.     public function setCheckedBy(?Employee $checkedBy): self
  142.     {
  143.         $this->checkedBy $checkedBy;
  144.         return $this;
  145.     }
  146.     public function getSerialId(): string
  147.     {
  148.         return "{$this->getSerial()}-{$this->getId()}";
  149.     }
  150.     public function __toString(): string
  151.     {
  152.         return "$this->number pour {$this->getLot()->getConfiguration()->getName()}";
  153.     }
  154. }