src/Entity/Vin.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Traits\UuidEntityTrait;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. /**
  9.  * @ORM\Entity()
  10.  * @ORM\Table(indexes={
  11.  *  @ORM\Index(name="idx_vin_created_at", columns={"created_at"}), 
  12.  *  @ORM\Index(name="idx_vin_vin", columns={"vin"}
  13.  * )})
  14.  */
  15. class Vin
  16. {
  17.     use UuidEntityTrait;
  18.     /**
  19.      * @ORM\Column(type="string", length=20, unique=true)
  20.      */
  21.     #[Groups(['index''orderHistory'])]
  22.     private string $vin;
  23.     /**
  24.      * @ORM\Column(type="string", length=255, nullable=true)
  25.      */
  26.     #[Groups(['index'])]
  27.     private ?string $region null;
  28.     /**
  29.      * @ORM\Column(type="string", length=255, nullable=true)
  30.      */
  31.     #[Groups(['index'])]
  32.     private ?string $country null;
  33.     /**
  34.      * @ORM\Column(type="string", length=255, nullable=true)
  35.      */
  36.     #[Groups(['index'])]
  37.     private ?string $model null;
  38.     /**
  39.      * @ORM\Column(type="string", length=255, nullable=true)
  40.      */
  41.     #[Groups(['index'])]
  42.     private ?string $fullModel null;
  43.     /**
  44.      * @ORM\Column(type="string", length=255, nullable=true)
  45.      */
  46.     #[Groups(['index'])]
  47.     private ?string $manufacturer null;
  48.     /**
  49.      * @ORM\Column(type="integer", nullable=true)
  50.      */
  51.     #[Groups(['index'])]
  52.     private ?int $year null;
  53.     /**
  54.      * @ORM\Column(type="boolean")
  55.      */
  56.     #[Groups(['index'])]
  57.     private bool $ready false;
  58.     /**
  59.      * @ORM\Column(type="boolean", nullable=true)
  60.      */
  61.     #[Groups(['index'])]
  62.     private ?bool $checkSum null;
  63.     /**
  64.      * @ORM\ManyToMany(targetEntity=ReportType::class)
  65.      *
  66.      * @var Collection<int, ReportType>
  67.      */
  68.     #[Groups(['index'])]
  69.     private Collection $reportTypes;
  70.     /**
  71.      * @ORM\OneToMany(targetEntity=Order::class, mappedBy="vin")
  72.      */
  73.     #[Groups(['order'])]
  74.     private Collection $orders;
  75.     /**
  76.      * @ORM\Column(type="datetime", nullable=true, options={"default": "CURRENT_TIMESTAMP"})
  77.      */
  78.     #[Groups(['order'])]
  79.     private ?\DateTimeInterface $createdAt null;
  80.     public function __construct()
  81.     {
  82.         $this->reportTypes = new ArrayCollection();
  83.         $this->orders = new ArrayCollection();
  84.     }
  85.     public function getVin(): string
  86.     {
  87.         return $this->vin;
  88.     }
  89.     public function setVin(string $vin): self
  90.     {
  91.         $this->vin $vin;
  92.         return $this;
  93.     }
  94.     public function getRegion(): ?string
  95.     {
  96.         return $this->region;
  97.     }
  98.     public function setRegion(?string $region): self
  99.     {
  100.         $this->region $region;
  101.         return $this;
  102.     }
  103.     public function getCountry(): ?string
  104.     {
  105.         return $this->country;
  106.     }
  107.     public function setCountry(?string $country): self
  108.     {
  109.         $this->country $country;
  110.         return $this;
  111.     }
  112.     public function getModel(): ?string
  113.     {
  114.         return $this->model;
  115.     }
  116.     public function setModel(?string $model): Vin
  117.     {
  118.         $this->model $model;
  119.         return $this;
  120.     }
  121.     public function getFullModel(): ?string
  122.     {
  123.         return $this->fullModel;
  124.     }
  125.     public function setFullModel(?string $fullModel): Vin
  126.     {
  127.         $this->fullModel $fullModel;
  128.         return $this;
  129.     }
  130.     public function getManufacturer(): ?string
  131.     {
  132.         return $this->manufacturer;
  133.     }
  134.     public function setManufacturer(?string $manufacturer): Vin
  135.     {
  136.         $this->manufacturer $manufacturer;
  137.         return $this;
  138.     }
  139.     public function getYear(): ?int
  140.     {
  141.         return $this->year;
  142.     }
  143.     public function setYear(?int $year): self
  144.     {
  145.         $this->year $year;
  146.         return $this;
  147.     }
  148.     public function isReady(): ?bool
  149.     {
  150.         return $this->ready;
  151.     }
  152.     public function setReady(bool $ready): Vin
  153.     {
  154.         $this->ready $ready;
  155.         return $this;
  156.     }
  157.     public function isCheckSum(): ?bool
  158.     {
  159.         return $this->checkSum;
  160.     }
  161.     public function setCheckSum(?bool $checkSum): Vin
  162.     {
  163.         $this->checkSum $checkSum;
  164.         return $this;
  165.     }
  166.     public function getReportTypes(): Collection
  167.     {
  168.         return $this->reportTypes;
  169.     }
  170.     public function addReportType(ReportType $reportType): self
  171.     {
  172.         if (!$this->containsReportType($reportType)) {
  173.             $this->reportTypes[] = $reportType;
  174.         }
  175.         return $this;
  176.     }
  177.     public function removeReportType(ReportType $reportType): self
  178.     {
  179.         $this->reportTypes->removeElement($reportType);
  180.         return $this;
  181.     }
  182.     public function getOrders(): Collection
  183.     {
  184.         return $this->orders;
  185.     }
  186.     public function addOrder(Order $order): self
  187.     {
  188.         if (!$this->orders->contains($order)) {
  189.             $this->orders[] = $order;
  190.             $order->setVin($this);
  191.         }
  192.         return $this;
  193.     }
  194.     public function removeOrder(Order $order): self
  195.     {
  196.         if ($this->orders->removeElement($order)) {
  197.             // set the owning side to null (unless already changed)
  198.             if ($order->getVin() === $this) {
  199.                 $order->setVin(null);
  200.             }
  201.         }
  202.         return $this;
  203.     }
  204.     public function containsReportType(ReportType $reportType): bool
  205.     {
  206.         foreach ($this->getReportTypes() as $rt) {
  207.             if (!$rt instanceof ReportType || ($rtId $rt->getId()) === null) {
  208.                 continue;
  209.             }
  210.             if ($rtId->equals($reportType->getId())) {
  211.                 return true;
  212.             }
  213.         }
  214.         return false;
  215.     }
  216.     public function __toString(): string
  217.     {
  218.         return $this->vin;
  219.     }
  220. }