src/Entity/ShopOrder.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ShopOrderRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. /**
  9.  * @ORM\Entity(repositoryClass=ShopOrderRepository::class)
  10.  */
  11. class ShopOrder
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=50)
  21.      */
  22.     private $reference;
  23.     /**
  24.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="shopOrders")
  25.      * @ORM\JoinColumn(nullable=false)
  26.      */
  27.     private $user;
  28.     /**
  29.      * @ORM\OneToMany(targetEntity=ShopOrderProduct::class, mappedBy="shop_order", cascade={"persist", "remove"})
  30.      */
  31.     private $shopOrderProducts;
  32.     /**
  33.     * @ORM\Column(type="datetime")
  34.     * @Gedmo\Timestampable(on="create")
  35.     */
  36.     private $createdAt;
  37.     /**
  38.      * @ORM\Column(type="datetime")
  39.      * @Gedmo\Timestampable(on="update")
  40.      */
  41.     private $updatedAt;
  42.     /**
  43.      * @ORM\Column(type="float")
  44.      */
  45.     private $total;
  46.     /**
  47.      * @ORM\ManyToOne(targetEntity=ShopOrderStatus::class, inversedBy="shopOrders")
  48.      * @ORM\JoinColumn(nullable=false)
  49.      */
  50.     private $status;
  51.     /**
  52.      * @ORM\ManyToOne(targetEntity=ShopUserAdress::class, inversedBy="commandes")
  53.      * @ORM\JoinColumn(nullable=false)
  54.      */
  55.     private $adress;
  56.     public function __construct()
  57.     {
  58.         $this->shopOrderProducts = new ArrayCollection();
  59.     }
  60.     public function getId(): ?int
  61.     {
  62.         return $this->id;
  63.     }
  64.     public function getReference(): ?string
  65.     {
  66.         return $this->reference;
  67.     }
  68.     public function setReference(string $reference): self
  69.     {
  70.         $this->reference $reference;
  71.         return $this;
  72.     }
  73.     public function getUser(): ?User
  74.     {
  75.         return $this->user;
  76.     }
  77.     public function setUser(?User $user): self
  78.     {
  79.         $this->user $user;
  80.         return $this;
  81.     }
  82.     /**
  83.      * @return Collection|ShopOrderProduct[]
  84.      */
  85.     
  86.     public function getShopOrderProducts(): Collection
  87.     {
  88.         return $this->shopOrderProducts;
  89.     }
  90.     public function addShopOrderProduct(ShopOrderProduct $shopOrderProduct): self
  91.     {
  92.         if (!$this->shopOrderProducts->contains($shopOrderProduct)) {
  93.             $this->shopOrderProducts[] = $shopOrderProduct;
  94.             $shopOrderProduct->setShopOrder($this);
  95.         }
  96.         return $this;
  97.     }
  98.     public function removeShopOrderProduct(ShopOrderProduct $shopOrderProduct): self
  99.     {
  100.         if ($this->shopOrderProducts->removeElement($shopOrderProduct)) {
  101.             // set the owning side to null (unless already changed)
  102.             if ($shopOrderProduct->getShopOrder() === $this) {
  103.                 $shopOrderProduct->setShopOrder(null);
  104.             }
  105.         }
  106.         return $this;
  107.     }
  108.     public function getCreatedAt(): ?\DateTimeInterface {
  109.                                             return $this->createdAt;
  110.                                         }
  111.     
  112.     public function setCreatedAt(?\DateTimeInterface $createdAt): self {
  113.                                             $this->createdAt $createdAt;
  114.                                                                                                          
  115.                                             return $this;
  116.                                         }
  117.     
  118.     public function getUpdatedAt(): ?\DateTimeInterface {
  119.                                             return $this->updatedAt;
  120.                                         }
  121.     
  122.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self {
  123.                                             $this->updatedAt $updatedAt;
  124.                                                                                                          
  125.                                             return $this;
  126.                                         }
  127.     public function getTotal(): ?float
  128.     {
  129.         return $this->total;
  130.     }
  131.     public function setTotal(float $total): self
  132.     {
  133.         $this->total $total;
  134.         return $this;
  135.     }
  136.     public function getStatus(): ?ShopOrderStatus
  137.     {
  138.         return $this->status;
  139.     }
  140.     public function setStatus(?ShopOrderStatus $status): self
  141.     {
  142.         $this->status $status;
  143.         return $this;
  144.     }
  145.     public function getTotalPoints(): ?int
  146.     {
  147.         $totalPoints 0;
  148.         foreach($this->getShopOrderProducts() as $shopOrderProduct){
  149.             $totalPoints += $shopOrderProduct->getTotalPoints();
  150.         }
  151.         return $totalPoints;
  152.     }
  153.     public function getAdress(): ?ShopUserAdress
  154.     {
  155.         return $this->adress;
  156.     }
  157.     public function setAdress(?ShopUserAdress $adress): self
  158.     {
  159.         $this->adress $adress;
  160.         return $this;
  161.     }
  162. }