src/Entity/Shipment.php line 15
<?phpnamespace App\Entity;use App\Kimia;use App\Repository\ShipmentRepository;use App\Trait\CurrentStateTrait;use DateTimeImmutable;use DateTimeInterface;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation\Groups;#[ORM\Entity(repositoryClass: ShipmentRepository::class)]class Shipment{use CurrentStateTrait;#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]#[Groups(['order:list'])]private ?int $id = null;#[ORM\Column(length: 255)]#[Groups(['order:list'])]private ?string $trackingNumber = null;#[ORM\Column(type: Types::DATETIME_MUTABLE)]#[Groups(['order:list'])]private ?DateTimeInterface $createdAt = null;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]#[Groups(['order:list'])]private ?DateTimeInterface $shippedAt = null;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]#[Groups(['order:list'])]private ?DateTimeInterface $deliveredAt = null;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]#[Groups(['order:list'])]private ?DateTimeInterface $cancelledAt = null;#[ORM\ManyToOne(cascade: ["persist", "remove"])]#[ORM\JoinColumn(nullable: false)]#[Groups(['order:list'])]private ?Address $destination = null;#[ORM\Column(nullable: true)]private ?float $amount = null;#[ORM\ManyToOne]#[ORM\JoinColumn(nullable: true)]private ?Currency $currency = null;#[ORM\ManyToOne(inversedBy: 'shipment')]#[ORM\JoinColumn(nullable: false)]private ?Order $command = null;#[ORM\ManyToOne]#[ORM\JoinColumn(nullable: false)]private ?User $author = null;public function __construct(){$this->currentState = "notShipped";if (is_null($this->createdAt)) $this->createdAt = new DateTimeImmutable();if (is_null($this->trackingNumber)) $this->trackingNumber = strtoupper(uniqid('TN-', false));}public function getId(): ?int{return $this->id;}public function getTrackingNumber(): ?string{return $this->trackingNumber;}public function setTrackingNumber(string $trackingNumber): self{$this->trackingNumber = $trackingNumber;return $this;}public static function getCurrentStateListForView(): array{return [Kimia::STATUS_INIT => "<span class='badge badge-soft-info'>Initié</span>",Kimia::STATUS_SUCCESS => "<span class='badge badge-soft-success'>Succès</span>",Kimia::STATUS_PROCESS => "<span class='badge badge-soft-warning'>En cours</span>",Kimia::STATUS_ERROR => "<span class='badge badge-soft-danger'>Erreur</span>",Kimia::STATUS_CANCEL => "<span class='badge badge-soft-secondary'>Annulé</span>",];}public function getCreatedAt(): ?DateTimeInterface{return $this->createdAt;}public function setCreatedAt(DateTimeInterface $createdAt): self{$this->createdAt = $createdAt;return $this;}public function getShippedAt(): ?DateTimeInterface{return $this->shippedAt;}public function setShippedAt(?DateTimeInterface $shippedAt): self{$this->shippedAt = $shippedAt;return $this;}public function getDeliveredAt(): ?DateTimeInterface{return $this->deliveredAt;}public function setDeliveredAt(?DateTimeInterface $deliveredAt): self{$this->deliveredAt = $deliveredAt;return $this;}public function getCancelledAt(): ?DateTimeInterface{return $this->cancelledAt;}public function setCancelledAt(?DateTimeInterface $cancelledAt): self{$this->cancelledAt = $cancelledAt;return $this;}public function getDestination(): ?Address{return $this->destination;}public function setDestination(?Address $destination): self{$this->destination = $destination;return $this;}public function getAmount(): ?float{return $this->amount;}public function setAmount(?float $amount): self{$this->amount = $amount;return $this;}public function getCurrency(): ?Currency{return $this->currency;}public function setCurrency(?Currency $currency): self{$this->currency = $currency;return $this;}public function getCommand(): ?Order{return $this->command;}public function setCommand(?Order $command): self{$this->command = $command;return $this;}public function getAuthor(): ?User{return $this->author;}public function setAuthor(?User $author): self{$this->author = $author;return $this;}public function __toString(): string{return $this->trackingNumber;}}