src/Entity/Product.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use App\Repository\ProductRepository;
  7. use Doctrine\ORM\Mapping\InheritanceType;
  8. use Doctrine\ORM\Mapping\DiscriminatorMap;
  9. use Doctrine\ORM\Mapping\DiscriminatorColumn;
  10. /**
  11.  * @ORM\Entity(repositoryClass=ProductRepository::class)
  12.  * @ORM\InheritanceType("JOINED")
  13.  * @ORM\DiscriminatorColumn(name="category", type="integer")
  14.  * @ORM\DiscriminatorMap({
  15.  *      "1" = "Vinyl",
  16.  *      "2" = "Cd",
  17.  *      "3" = "Accessory"
  18.  * })
  19.  */
  20. abstract class Product
  21. {
  22.     /**
  23.      * @ORM\Id
  24.      * @ORM\GeneratedValue
  25.      * @ORM\Column(type="integer")
  26.      */
  27.     protected $id;
  28.     /**
  29.      * @ORM\Column(type="string", length=255)
  30.      */
  31.     private $ref;
  32.     /**
  33.      * @ORM\Column(type="string", length=255)
  34.      */
  35.     private $designation;
  36.     /**
  37.      * @ORM\ManyToOne(targetEntity=Category::class, inversedBy="products")
  38.      * @ORM\JoinColumn(nullable=false)
  39.      */
  40.     private $category;
  41.     /**
  42.      * @ORM\Column(type="datetime_immutable")
  43.      */
  44.     private $createdAt;
  45.     /**
  46.      * @ORM\Column(type="float")
  47.      */
  48.     private $price;
  49.     /**
  50.      * @ORM\Column(type="datetime_immutable", nullable=true)
  51.      */
  52.     private $updatedAt;
  53.     /**
  54.      * @ORM\Column(type="float", nullable=true)
  55.      */
  56.     private $promo;
  57.     /**
  58.      * @ORM\Column(type="text", nullable=true)
  59.      */
  60.     private $description;
  61.     /**
  62.      * @ORM\Column(type="string", length=100, unique=true)
  63.      */
  64.     private $slug;
  65.     /**
  66.      * @ORM\Column(type="smallint", nullable=true)
  67.      */
  68.     private $quantity;
  69.     /**
  70.      * @ORM\ManyToMany(targetEntity=Promote::class, inversedBy="products")
  71.      */
  72.     private $promotes;
  73.     /**
  74.      * @ORM\OneToMany(targetEntity=Detail::class, mappedBy="product")
  75.      */
  76.     private $orders;
  77.     /**
  78.      * @ORM\Column(type="smallint", nullable=true)
  79.      */
  80.     private $weight;
  81.     public function __construct()
  82.     {
  83.         $this->promotes = new ArrayCollection();
  84.         $this->orders = new ArrayCollection();
  85.     }
  86.     public function getId(): ?int
  87.     {
  88.         return $this->id;
  89.     }
  90.     public function getRef(): ?string
  91.     {
  92.         return $this->ref;
  93.     }
  94.     public function setRef(string $ref): self
  95.     {
  96.         $this->ref $ref;
  97.         return $this;
  98.     }
  99.     public function getDesignation(): ?string
  100.     {
  101.         return $this->designation;
  102.     }
  103.     public function setDesignation(string $designation): self
  104.     {
  105.         $this->designation $designation;
  106.         return $this;
  107.     }
  108.     public function getCategory(): ?Category
  109.     {
  110.         return $this->category;
  111.     }
  112.     public function setCategory(?Category $category): self
  113.     {
  114.         $this->category $category;
  115.         return $this;
  116.     }
  117.     public function getCreatedAt(): ?\DateTimeImmutable
  118.     {
  119.         return $this->createdAt;
  120.     }
  121.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  122.     {
  123.         $this->createdAt $createdAt;
  124.         return $this;
  125.     }
  126.     public function getPrice(): ?float
  127.     {
  128.         return $this->price;
  129.     }
  130.     public function setPrice(float $price): self
  131.     {
  132.         $this->price $price;
  133.         return $this;
  134.     }
  135.     public function getUpdatedAt(): ?\DateTimeImmutable
  136.     {
  137.         return $this->updatedAt;
  138.     }
  139.     public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
  140.     {
  141.         $this->updatedAt $updatedAt;
  142.         return $this;
  143.     }
  144.     public function getPromo(): ?float
  145.     {
  146.         return $this->promo;
  147.     }
  148.     public function setPromo(?float $promo): self
  149.     {
  150.         $this->promo $promo;
  151.         return $this;
  152.     }
  153.     public function getDescription(): ?string
  154.     {
  155.         return $this->description;
  156.     }
  157.     public function setDescription(?string $description): self
  158.     {
  159.         $this->description $description;
  160.         return $this;
  161.     }
  162.     public function getSlug(): ?string
  163.     {
  164.         return $this->slug;
  165.     }
  166.     public function setSlug(string $slug): self
  167.     {
  168.         $this->slug $slug;
  169.         return $this;
  170.     }
  171.     public function getQuantity(): ?int
  172.     {
  173.         return $this->quantity;
  174.     }
  175.     public function setQuantity(?int $quantity): self
  176.     {
  177.         $this->quantity $quantity;
  178.         return $this;
  179.     }
  180.     /**
  181.      * @return Collection|Promote[]
  182.      */
  183.     public function getPromotes(): ?Collection
  184.     {
  185.         return $this->promotes;
  186.     }
  187.     public function addPromote(Promote $promote): self
  188.     {
  189.         if (!$this->promotes) {
  190.             $this->promotes = new ArrayCollection();
  191.         }
  192.         if (!$this->promotes->contains($promote)) {
  193.             $this->promotes[] = $promote;
  194.         }
  195.         return $this;
  196.     }
  197.     public function removePromote(Promote $promote): self
  198.     {
  199.         $this->promotes->removeElement($promote);
  200.         return $this;
  201.     }
  202.     /**
  203.      * @return Collection
  204.      */
  205.     public function getOrders(): Collection
  206.     {
  207.         return $this->orders;
  208.     }
  209.     public function addOrder(Detail $order): self
  210.     {
  211.         if (!$this->orders->contains($order)) {
  212.             $this->orders[] = $order;
  213.             $order->setProduct($this);
  214.         }
  215.         return $this;
  216.     }
  217.     public function removeOrder(Detail $order): self
  218.     {
  219.         if ($this->orders->removeElement($order)) {
  220.             // set the owning side to null (unless already changed)
  221.             if ($order->getProduct() === $this) {
  222.                 $order->setProduct(null);
  223.             }
  224.         }
  225.         return $this;
  226.     }
  227.     public function getWeight(): ?int
  228.     {
  229.         return $this->weight;
  230.     }
  231.     public function setWeight(?int $weight): self
  232.     {
  233.         $this->weight $weight;
  234.         return $this;
  235.     }
  236. }