src/Entity/NielsenOrder.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Interfaces\MarkingsInterface;
  4. use App\Entity\Traits\MarkingsTrait;
  5. use App\Entity\Traits\MarkingTrait;
  6. use App\Repository\NielsenOrderRepository;
  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. #[ORM\Entity(repositoryClassNielsenOrderRepository::class)]
  12. class NielsenOrder implements MarkingsInterface
  13. {
  14.     use MarkingTrait;
  15.     use MarkingsTrait;
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column]
  19.     private ?int $id null;
  20.     #[ORM\ManyToOne(inversedBy'nielsenOrders')]
  21.     private ?Project $project null;
  22.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  23.     private ?\DateTimeInterface $created null;
  24.     #[ORM\ManyToMany(targetEntityClientOrder::class, inversedBy'nielsenOrders')]
  25.     private Collection $clientOrders;
  26.     #[ORM\Column(length255nullabletrue)]
  27.     private ?string $status null;
  28.     #[ORM\Column(length255nullabletrue)]
  29.     private ?string $reference null;
  30.     #[ORM\OneToMany(mappedBy'entity'targetEntityNielsenOrderMarking::class, orphanRemovaltrue)]
  31.     #[ORM\OrderBy(['createdAt' => 'ASC'])]
  32.     private Collection $markings;
  33.     #[ORM\Column(typeTypes::JSON)]
  34.     private array $shipments = [];
  35.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  36.     private ?\DateTimeInterface $updatedAt null;
  37.     public function __construct()
  38.     {
  39.         $this->clientOrders = new ArrayCollection();
  40.         $this->created = new \DateTimeImmutable();
  41.         $this->markings = new ArrayCollection();
  42.         $this->marking NielsenOrderMarking::getInitialMarking();
  43.     }
  44.     public function getId(): ?int
  45.     {
  46.         return $this->id;
  47.     }
  48.     public function getProject(): ?Project
  49.     {
  50.         return $this->project;
  51.     }
  52.     public function setProject(?Project $project): static
  53.     {
  54.         $this->project $project;
  55.         return $this;
  56.     }
  57.     public function getCreated(): ?\DateTimeInterface
  58.     {
  59.         return $this->created;
  60.     }
  61.     public function setCreated(\DateTimeInterface $created): static
  62.     {
  63.         $this->created $created;
  64.         return $this;
  65.     }
  66.     /**
  67.      * @return Collection<int, ClientOrder>
  68.      */
  69.     public function getClientOrders(): Collection
  70.     {
  71.         return $this->clientOrders;
  72.     }
  73.     public function addClientOrder(ClientOrder $clientOrder): static
  74.     {
  75.         if (!$this->clientOrders->contains($clientOrder)) {
  76.             $this->clientOrders->add($clientOrder);
  77.         }
  78.         return $this;
  79.     }
  80.     public function removeClientOrder(ClientOrder $clientOrder): static
  81.     {
  82.         $this->clientOrders->removeElement($clientOrder);
  83.         return $this;
  84.     }
  85.     public function getStatus(): ?string
  86.     {
  87.         return $this->status;
  88.     }
  89.     public function setStatus(?string $status): static
  90.     {
  91.         $this->status $status;
  92.         return $this;
  93.     }
  94.     public function getReference(): ?string
  95.     {
  96.         return $this->reference;
  97.     }
  98.     public function setReference(?string $reference): static
  99.     {
  100.         $this->reference $reference;
  101.         return $this;
  102.     }
  103.     public function getShipments(): array
  104.     {
  105.         return $this->shipments;
  106.     }
  107.     public function setShipments(array $shipments): static
  108.     {
  109.         $this->shipments $shipments;
  110.         return $this;
  111.     }
  112.     public function addShipment(
  113.         \DateTime $date,
  114.         ?string $shippingNumber,
  115.         string $trackingLink,
  116.     ): self
  117.     {
  118.         $this->shipments[] = [
  119.             'date' => $date->format("Y-m-d H:i:s"),
  120.             'shipping_number' => $shippingNumber ?? null,
  121.             'tracking_link' => $trackingLink,
  122.         ];
  123.         return $this;
  124.     }
  125.     public function getUpdatedAt(): ?\DateTimeInterface
  126.     {
  127.         return $this->updatedAt;
  128.     }
  129.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): static
  130.     {
  131.         $this->updatedAt $updatedAt;
  132.         return $this;
  133.     }
  134. }