<?phpnamespace App\Entity;use App\Repository\OrderRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass=OrderRepository::class) * @ORM\Table(name="`order`") */class Order{    /**     * @ORM\Id     * @ORM\GeneratedValue     * @ORM\Column(type="integer")     */    private $id;    /**     * @ORM\ManyToOne(targetEntity=User::class, inversedBy="orders")     * @ORM\JoinColumn(nullable=false)     */    private $user;    /**     * @ORM\Column(type="datetime_immutable")     */    private $created_at;    /**     * @ORM\Column(type="string", length=255)     */    private $carrierName;    /**     * @ORM\Column(type="float")     */    private $carrierPrice;    /**     * @ORM\Column(type="text")     */    private $delivery;    /**     * @ORM\OneToMany(targetEntity=OrderDetails::class, mappedBy="myOrder")     */    private $orderDetails;    public function __construct()    {        $this->orderDetails = new ArrayCollection();    }    public function getTotal(){        $total = null;        foreach($this->getOrderDetails()->getValues() as $product){            $total = $total + ($product->getPrice() * $product->getQuantity());        }        return $total;    }     /**     * @ORM\Column(type="boolean")     */    private $paid;    /**     * @ORM\Column(type="string", length=255)     */    private $reference;    /**     * @ORM\Column(type="string", length=255)     */    private $stripeSessionId;    public function getPaid(): bool {        return $this->paid;    }    public function setPaid(bool $paid): void {        $this->paid = $paid;    }    public function getId(): ?int    {        return $this->id;    }    public function setId(int $id): self    {        $this->id = $id;        return $this;    }    public function getUser(): ?user    {        return $this->user;    }    public function setUser(?user $user): self    {        $this->user = $user;        return $this;    }    public function getCreatedAt(): ?\DateTimeImmutable    {        return $this->created_at;    }    public function setCreatedAt(\DateTime $created_at): self    {        $immutable_created_at = \DateTimeImmutable::createFromMutable($created_at);            $this->created_at = $immutable_created_at;            return $this;    }        public function getCarrierName(): ?string    {        return $this->carrierName;    }    public function setCarrierName(string $carrierName): self    {        $this->carrierName = $carrierName;        return $this;    }    public function getCarrierPrice(): ?float    {        return $this->carrierPrice;    }    public function setCarrierPrice(float $carrierPrice): self    {        $this->carrierPrice = $carrierPrice;        return $this;    }    public function getDelivery(): ?string    {        return $this->delivery;    }    public function setDelivery(string $delivery): self    {        $this->delivery = $delivery;        return $this;    }    /**     * @return Collection<int, OrderDetails>     */    public function getOrderDetails(): Collection    {        return $this->orderDetails;    }    public function addOrderDetail(OrderDetails $orderDetail): self    {        if (!$this->orderDetails->contains($orderDetail)) {            $this->orderDetails[] = $orderDetail;            $orderDetail->setMyOrder($this);        }        return $this;    }    public function removeOrderDetail(OrderDetails $orderDetail): self    {        if ($this->orderDetails->removeElement($orderDetail)) {            // set the owning side to null (unless already changed)            if ($orderDetail->getMyOrder() === $this) {                $orderDetail->setMyOrder(null);            }        }        return $this;    }    public function getReference(): ?string    {        return $this->reference;    }    public function setReference(string $reference): self    {        $this->reference = $reference;        return $this;    }    public function getStripeSessionId(): ?string    {        return $this->stripeSessionId;    }    public function setStripeSessionId(string $stripeSessionId): self    {        $this->stripeSessionId = $stripeSessionId;        return $this;    }}