src/Entity/Order.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use App\Repository\OrderRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. /**
  12.  * @ORM\Entity(repositoryClass=OrderRepository::class)
  13.  * @ORM\Table(name="`order`")
  14.  * @ApiResource(
  15.  *     collectionOperations={"get","post"},
  16.  *     itemOperations={"get", "put"},
  17.  *     normalizationContext={"groups"={"order"}},
  18.  *     denormalizationContext={"groups"={"order"}},
  19.  *     attributes={"pagination_enabled"=false}
  20.  * )
  21.  * @ApiFilter(
  22.  *      BooleanFilter::class, properties={"isArchived", "isSaved"}
  23.  * )
  24.  */
  25. class Order
  26. {
  27.     /**
  28.      * @ORM\Id
  29.      * @ORM\GeneratedValue
  30.      * @ORM\Column(type="integer")
  31.      * @Groups("order")
  32.      */
  33.     private $id;
  34.     /**
  35.      * @ORM\Column(type="datetime", nullable = true)
  36.      * @Groups("order")
  37.      */
  38.     private $date;
  39.     /**
  40.      * @ORM\Column(type="float")
  41.      * @Groups("order")
  42.      */
  43.     private $amount;
  44.     /**
  45.      * @ORM\Column(type="text", nullable=true)
  46.      * @Groups("order")
  47.      */
  48.     private $comment;
  49.     /**
  50.      * @ORM\OneToMany(targetEntity=OrderMovement::class, mappedBy="command", cascade={"persist", "remove"})
  51.      * @Groups("order")
  52.      */
  53.     private $orderMovement;
  54.     /**
  55.      * @ORM\Column(type="boolean")
  56.      * @Groups("order")
  57.      */
  58.     private $isValidated;
  59.     /**
  60.      * @ORM\Column(type="boolean")
  61.      * @Groups("order")
  62.      */
  63.     private $isSaved;
  64.     /**
  65.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="orders")
  66.      * @Groups("order")
  67.      */
  68.     private $user;
  69.     /**
  70.      * @ORM\Column(type="boolean")
  71.      * @Groups("order")
  72.      */
  73.     private $isArchived;
  74.     /**
  75.      * @ORM\Column(type="integer", nullable=true)
  76.      * @Groups("order")
  77.      */
  78.     private $orderNumber;
  79.     /**
  80.      * @ORM\Column(type="datetime", nullable=true)
  81.      * @Groups("order")
  82.      */
  83.     private $deliveryDate;
  84.     /**
  85.      * @ORM\Column(type="text", nullable=true)
  86.      * @Groups("order")
  87.      */
  88.     private $adminComment;
  89.     /**
  90.      * @ORM\Column(type="float", nullable=true)
  91.      */
  92.     private $shippingCosts;
  93.     /**
  94.      * @ORM\Column(type="string", length=255, nullable=true)
  95.      */
  96.     private $customerAdmin;
  97.     public function __construct()
  98.     {
  99.         $this->orderMovement = new ArrayCollection();
  100.     }
  101.     public function getId(): ?int
  102.     {
  103.         return $this->id;
  104.     }
  105.     public function getDate(): ?\DateTimeInterface
  106.     {
  107.         return $this->date;
  108.     }
  109.     public function setDate(\DateTimeInterface $date): self
  110.     {
  111.         $this->date $date;
  112.         return $this;
  113.     }
  114.     public function getAmount(): ?float
  115.     {
  116.         return $this->amount;
  117.     }
  118.     public function setAmount(float $amount): self
  119.     {
  120.         $this->amount $amount;
  121.         return $this;
  122.     }
  123.     public function getComment(): ?string
  124.     {
  125.         return $this->comment;
  126.     }
  127.     public function setComment(?string $comment): self
  128.     {
  129.         $this->comment $comment;
  130.         return $this;
  131.     }
  132.     /**
  133.      * @return Collection|OrderMovement[]
  134.      */
  135.     public function getOrderMovement(): Collection
  136.     {
  137.         return $this->orderMovement;
  138.     }
  139.     public function addOrderMovement(OrderMovement $orderMovement): self
  140.     {
  141.         if (!$this->orderMovement->contains($orderMovement)) {
  142.             $this->orderMovement[] = $orderMovement;
  143.             $orderMovement->setCommand($this);
  144.         }
  145.         return $this;
  146.     }
  147.     public function removeOrderMovement(OrderMovement $orderMovement): self
  148.     {
  149.         if ($this->orderMovement->removeElement($orderMovement)) {
  150.             // set the owning side to null (unless already changed)
  151.             if ($orderMovement->getCommand() === $this) {
  152.                 $orderMovement->setCommand(null);
  153.             }
  154.         }
  155.         return $this;
  156.     }
  157.     public function getIsValidated(): ?bool
  158.     {
  159.         return $this->isValidated;
  160.     }
  161.     public function setIsValidated(bool $isValidated): self
  162.     {
  163.         $this->isValidated $isValidated;
  164.         return $this;
  165.     }
  166.     public function getIsSaved(): ?bool
  167.     {
  168.         return $this->isSaved;
  169.     }
  170.     public function setIsSaved(bool $isSaved): self
  171.     {
  172.         $this->isSaved $isSaved;
  173.         return $this;
  174.     }
  175.     public function getUser(): ?User
  176.     {
  177.         return $this->user;
  178.     }
  179.     public function setUser(?User $user): self
  180.     {
  181.         $this->user $user;
  182.         return $this;
  183.     }
  184.     public function getIsArchived(): ?bool
  185.     {
  186.         return $this->isArchived;
  187.     }
  188.     public function setIsArchived(bool $isArchived): self
  189.     {
  190.         $this->isArchived $isArchived;
  191.         return $this;
  192.     }
  193.     public function getOrderNumber(): ?int
  194.     {
  195.         return $this->orderNumber;
  196.     }
  197.     public function setOrderNumber(?int $orderNumber): self
  198.     {
  199.         $this->orderNumber $orderNumber;
  200.         return $this;
  201.     }
  202.     public function getDeliveryDate(): ?\DateTimeInterface
  203.     {
  204.         return $this->deliveryDate;
  205.     }
  206.     public function setDeliveryDate(\DateTimeInterface $deliveryDate): self
  207.     {
  208.         $this->deliveryDate $deliveryDate;
  209.         return $this;
  210.     }
  211.     public function getAdminComment(): ?string
  212.     {
  213.         return $this->adminComment;
  214.     }
  215.     public function setAdminComment(?string $adminComment): self
  216.     {
  217.         $this->adminComment $adminComment;
  218.         return $this;
  219.     }
  220.     public function getShippingCosts(): ?float
  221.     {
  222.         return $this->shippingCosts;
  223.     }
  224.     public function setShippingCosts(?float $shippingCosts): self
  225.     {
  226.         $this->shippingCosts $shippingCosts;
  227.         return $this;
  228.     }
  229.     public function getCustomerAdmin(): ?string
  230.     {
  231.         return $this->customerAdmin;
  232.     }
  233.     public function setCustomerAdmin(?string $customerAdmin): self
  234.     {
  235.         $this->customerAdmin $customerAdmin;
  236.         return $this;
  237.     }
  238. }