src/Order/Doctrine/Entity/Detail.php line 20

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Order\Doctrine\Entity;
  4. use App\Shop\Doctrine\Entity\Product;
  5. use App\Supplier\Doctrine\Entity\Supplier;
  6. use DateTimeImmutable;
  7. use Doctrine\ORM\Mapping\Column;
  8. use Doctrine\ORM\Mapping\Entity;
  9. use Doctrine\ORM\Mapping\GeneratedValue;
  10. use Doctrine\ORM\Mapping\Id;
  11. use Doctrine\ORM\Mapping\JoinColumn;
  12. use Doctrine\ORM\Mapping\ManyToOne;
  13. use Doctrine\ORM\Mapping\Table;
  14. #[Entity]
  15. #[Table(name: 'order_detail')]
  16. class Detail
  17. {
  18.     #[Id]
  19.     #[Column(type: 'integer')]
  20.     #[GeneratedValue]
  21.     private ?int $id = null;
  22.     private bool $used = true;
  23.     #[ManyToOne(targetEntity: Order::class, inversedBy: 'details')]
  24.     #[JoinColumn(nullable: false, onDelete: 'CASCADE')]
  25.     private Order $order;
  26.     #[ManyToOne(targetEntity: Line::class)]
  27.     #[JoinColumn(nullable: false, onDelete: 'CASCADE')]
  28.     private Line $line;
  29.     #[ManyToOne(targetEntity: Product::class)]
  30.     #[JoinColumn(nullable: false)]
  31.     private Product $product;
  32.     #[ManyToOne(targetEntity: Bill::class, inversedBy: 'details')]
  33.     #[JoinColumn(onDelete: 'SET NULL')]
  34.     private ?Bill $bill = null;
  35.     #[Column]
  36.     private string $state = 'in_progress';
  37.     #[Column(type: 'datetime_immutable')]
  38.     private DateTimeImmutable $updatedAt;
  39.     /**
  40.      * @var array<array-key, array{state: string, date: string}>
  41.      */
  42.     #[Column(type: 'array')]
  43.     private array $history = [];
  44.     #[ManyToOne(targetEntity: Carrier::class)]
  45.     private ?Carrier $carrier = null;
  46.     #[Column(nullable: true)]
  47.     private ?string $tracking = null;
  48.     #[ManyToOne(targetEntity: Supplier::class, cascade: ['persist'])]
  49.     private ?Supplier $supplier = null;
  50.     #[Column(nullable: true)]
  51.     private ?string $reference = null;
  52.     #[Column(nullable: true, name: '`reference_comm`')]
  53.     private ?string $referenceComm = null;
  54.     #[Column(nullable: true)]
  55.     private ?int $price = null;
  56.     #[Column(type: 'date_immutable', nullable: true)]
  57.     private ?DateTimeImmutable $date = null;
  58.     #[Column(nullable: true)]
  59.     private ?string $numberOrder = null;
  60.     public function __construct()
  61.     {
  62.         $this->updatedAt = new DateTimeImmutable();
  63.         $this->addStateHistory('in_progress');
  64.     }
  65.     public function getId(): ?int
  66.     {
  67.         return $this->id;
  68.     }
  69.     public function getOrder(): Order
  70.     {
  71.         return $this->order;
  72.     }
  73.     public function setOrder(Order $order): void
  74.     {
  75.         $this->order = $order;
  76.     }
  77.     public function getProduct(): Product
  78.     {
  79.         return $this->product;
  80.     }
  81.     public function setProduct(Product $product): void
  82.     {
  83.         $this->product = $product;
  84.     }
  85.     public function getState(): string
  86.     {
  87.         return $this->state;
  88.     }
  89.     public function setState(string $state): void
  90.     {
  91.         $this->state = $state;
  92.     }
  93.     public function getUpdatedAt(): DateTimeImmutable
  94.     {
  95.         return $this->updatedAt;
  96.     }
  97.     public function setUpdatedAt(DateTimeImmutable $updatedAt): void
  98.     {
  99.         $this->updatedAt = $updatedAt;
  100.     }
  101.     /**
  102.      * @return array<array-key, array{state: string, date: string}>
  103.      */
  104.     public function getHistory(): array
  105.     {
  106.         return $this->history;
  107.     }
  108.     public function addStateHistory(string $state): void
  109.     {
  110.         $this->history[] = ['date' => date('Y-m-d H:i:s'), 'state' => $state];
  111.     }
  112.     public function getCarrier(): ?Carrier
  113.     {
  114.         return $this->carrier;
  115.     }
  116.     public function setCarrier(?Carrier $carrier): void
  117.     {
  118.         $this->carrier = $carrier;
  119.     }
  120.     public function getTracking(): ?string
  121.     {
  122.         return $this->tracking;
  123.     }
  124.     public function setTracking(?string $tracking): void
  125.     {
  126.         $this->tracking = $tracking;
  127.     }
  128.     public function getBill(): ?Bill
  129.     {
  130.         return $this->bill;
  131.     }
  132.     public function setBill(?Bill $bill): void
  133.     {
  134.         $this->bill = $bill;
  135.     }
  136.     public function getLine(): Line
  137.     {
  138.         return $this->line;
  139.     }
  140.     public function setLine(Line $line): void
  141.     {
  142.         $this->line = $line;
  143.     }
  144.     public function getSupplier(): ?Supplier
  145.     {
  146.         return $this->supplier;
  147.     }
  148.     public function setSupplier(?Supplier $supplier): void
  149.     {
  150.         $this->supplier = $supplier;
  151.     }
  152.     public function getReference(): ?string
  153.     {
  154.         return $this->reference;
  155.     }
  156.     public function setReference(?string $reference): void
  157.     {
  158.         $this->reference = $reference;
  159.     }
  160.     public function getPrice(): ?int
  161.     {
  162.         return $this->price;
  163.     }
  164.     public function setPrice(?int $price): void
  165.     {
  166.         $this->price = $price;
  167.     }
  168.     public function getDate(): ?DateTimeImmutable
  169.     {
  170.         return $this->date;
  171.     }
  172.     public function setDate(?DateTimeImmutable $date): void
  173.     {
  174.         $this->date = $date;
  175.     }
  176.     public function isUsed(): bool
  177.     {
  178.         return $this->used;
  179.     }
  180.     public function setUsed(bool $used): void
  181.     {
  182.         $this->used = $used;
  183.     }
  184.     public function getNumberOrder(): ?string
  185.     {
  186.         return $this->numberOrder;
  187.     }
  188.     public function setNumberOrder(?string $numberOrder): void
  189.     {
  190.         $this->numberOrder = $numberOrder;
  191.     }
  192.     public function getReferenceComm(): ?string
  193.     {
  194.         return $this->referenceComm;
  195.     }
  196.     public function setReferenceComm(?string $referenceComm): void
  197.     {
  198.         $this->referenceComm = $referenceComm;
  199.     }
  200. }