<?phpnamespace App\Entity;use App\Repository\ShopOrderRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Gedmo\Mapping\Annotation as Gedmo;/** * @ORM\Entity(repositoryClass=ShopOrderRepository::class) */class ShopOrder{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=50) */ private $reference; /** * @ORM\ManyToOne(targetEntity=User::class, inversedBy="shopOrders") * @ORM\JoinColumn(nullable=false) */ private $user; /** * @ORM\OneToMany(targetEntity=ShopOrderProduct::class, mappedBy="shop_order", cascade={"persist", "remove"}) */ private $shopOrderProducts; /** * @ORM\Column(type="datetime") * @Gedmo\Timestampable(on="create") */ private $createdAt; /** * @ORM\Column(type="datetime") * @Gedmo\Timestampable(on="update") */ private $updatedAt; /** * @ORM\Column(type="float") */ private $total; /** * @ORM\ManyToOne(targetEntity=ShopOrderStatus::class, inversedBy="shopOrders") * @ORM\JoinColumn(nullable=false) */ private $status; /** * @ORM\ManyToOne(targetEntity=ShopUserAdress::class, inversedBy="commandes") * @ORM\JoinColumn(nullable=false) */ private $adress; public function __construct() { $this->shopOrderProducts = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getReference(): ?string { return $this->reference; } public function setReference(string $reference): self { $this->reference = $reference; return $this; } public function getUser(): ?User { return $this->user; } public function setUser(?User $user): self { $this->user = $user; return $this; } /** * @return Collection|ShopOrderProduct[] */ public function getShopOrderProducts(): Collection { return $this->shopOrderProducts; } public function addShopOrderProduct(ShopOrderProduct $shopOrderProduct): self { if (!$this->shopOrderProducts->contains($shopOrderProduct)) { $this->shopOrderProducts[] = $shopOrderProduct; $shopOrderProduct->setShopOrder($this); } return $this; } public function removeShopOrderProduct(ShopOrderProduct $shopOrderProduct): self { if ($this->shopOrderProducts->removeElement($shopOrderProduct)) { // set the owning side to null (unless already changed) if ($shopOrderProduct->getShopOrder() === $this) { $shopOrderProduct->setShopOrder(null); } } return $this; } public function getCreatedAt(): ?\DateTimeInterface { return $this->createdAt; } public function setCreatedAt(?\DateTimeInterface $createdAt): self { $this->createdAt = $createdAt; return $this; } public function getUpdatedAt(): ?\DateTimeInterface { return $this->updatedAt; } public function setUpdatedAt(?\DateTimeInterface $updatedAt): self { $this->updatedAt = $updatedAt; return $this; } public function getTotal(): ?float { return $this->total; } public function setTotal(float $total): self { $this->total = $total; return $this; } public function getStatus(): ?ShopOrderStatus { return $this->status; } public function setStatus(?ShopOrderStatus $status): self { $this->status = $status; return $this; } public function getTotalPoints(): ?int { $totalPoints = 0; foreach($this->getShopOrderProducts() as $shopOrderProduct){ $totalPoints += $shopOrderProduct->getTotalPoints(); } return $totalPoints; } public function getAdress(): ?ShopUserAdress { return $this->adress; } public function setAdress(?ShopUserAdress $adress): self { $this->adress = $adress; return $this; }}