Skip to content
Snippets Groups Projects
Select Git revision
  • e6411eedc903eda51a808ca253093cd5984d16c3
  • main default protected
  • route
  • Controllers
4 results

ProductOrder.php

Blame
  • ProductOrder.php 1.24 KiB
    <?php
    
    use Doctrine\Common\Collections\ArrayCollection;
    use Doctrine\ORM\Mapping as ORM;
    
    /**
     * @ORM\Entity
     * @ORM\Table(name="productorder")
     */
    class ProductOrder
    {
        /** 
         * @var Product
         * @ORM\Id
         * @ORM\ManyToOne(targetEntity="Product", inversedBy="productOrders")
         */
        private $product;
        /** 
         * @ORM\Id
         * @var Order
         * @ORM\ManyToOne(targetEntity="Order", inversedBy="productOrders")
         */
        private $order;
        /**
         * @var int
         * @ORM\Column(type="integer")
         */
        private $quantity;
    
        public function getProduct(): Product
        {
            return $this->product;
        }
    
        public function setProduct(Product $product): bool
        {
            $this->product = $product;
            return true;
        }
    
        public function getOrder(): Order
        {
            return $this->order;
        }
    
        public function setOrder(Order $order): bool
        {
            $this->order = $order;
            return true;
        }
    
        public function getQuantity(): int
        {
            return $this->quantity;
        }
    
        public function setQuantity(int $quantity): bool
        {
            $this->quantity = $quantity;
            return true;
        }
    
        public function computePrice() 
        {
            return $this->product->getPrice() * $this->quantity;
        }
    }