src/Admin/Modules/Store/Entity/StoreProduct.php line 18

  1. <?php
  2. namespace App\Admin\Modules\Store\Entity;
  3. use App\Modules\User\Entity\User;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. use Gedmo\Translatable\Translatable;
  10. /**
  11.  * @ORM\Table(name="store_product", indexes={@ORM\Index(columns={"position"})})
  12.  * @ORM\Entity(repositoryClass="App\Admin\Modules\Store\Repository\StoreProductRepository")
  13.  * @Gedmo\TranslationEntity(class="App\Admin\Modules\Store\Entity\StoreProductTranslation")
  14.  */
  15. class StoreProduct implements Translatable
  16. {
  17.     /**
  18.      * @var int
  19.      *
  20.      * @ORM\Column(type="bigint", options={"unsigned"=true}))
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue(strategy="AUTO")
  23.      */
  24.     protected $id;
  25.     /**
  26.      * @var \App\Admin\Modules\Store\Entity\StoreCategory
  27.      *
  28.      * @ORM\ManyToOne(targetEntity="App\Admin\Modules\Store\Entity\StoreCategory", inversedBy="products")
  29.      * @ORM\JoinColumns({
  30.      *   @ORM\JoinColumn(name="id_store_category", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  31.      * })
  32.      */
  33.     private $category;
  34.     /**
  35.      * @var string
  36.      *
  37.      * @ORM\Column(name="name", type="string", length=255, nullable=false)
  38.      * @Gedmo\Translatable
  39.      */
  40.     private $name;
  41.     
  42.     /**
  43.      * @var string
  44.      *
  45.      * @ORM\Column(name="description", type="text", length=65535, nullable=false)
  46.      * @Gedmo\Translatable
  47.      */
  48.     private $description;
  49.     /**
  50.      * @var string
  51.      *
  52.      * @ORM\Column(name="price", type="decimal", precision=14, scale=2, nullable=false)
  53.      */
  54.     private $price;
  55.     
  56.     /**
  57.      * @var int
  58.      *
  59.      * @ORM\Column(name="vat", type="smallint", nullable=false)
  60.      */
  61.     private $vat;
  62.     
  63.     /**
  64.      * @var string
  65.      *
  66.      * @ORM\Column(name="weight", type="string", length=25, nullable=false)
  67.      */
  68.     private $weight;
  69.     /**
  70.      * @var int
  71.      *
  72.      * @ORM\Column(name="lead_time", type="smallint", nullable=false)
  73.      */
  74.     private $leadTime;
  75.     /**
  76.      * @var string
  77.      *
  78.      * @ORM\Column(name="image", type="string", length=255, nullable=true)
  79.      */
  80.     private $image;
  81.     /**
  82.      * @var int
  83.      *
  84.      * @ORM\Column(name="position", type="smallint", nullable=false)
  85.      */
  86.     private $position;    
  87.     /**
  88.      * @var \App\Modules\User\Entity\User
  89.      *
  90.      * @ORM\ManyToOne(targetEntity="App\Modules\User\Entity\User")
  91.      * @ORM\JoinColumns({
  92.      *   @ORM\JoinColumn(name="id_added_by", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  93.      * })
  94.      */
  95.     private $addedBy;
  96.     
  97.     /**
  98.      * @var \App\Admin\Modules\Store\Entity\StoreProductImage
  99.      *
  100.      * @ORM\OneToMany(targetEntity="App\Admin\Modules\Store\Entity\StoreProductImage", mappedBy="product", cascade={"persist"}, orphanRemoval=true)
  101.      * @ORM\OrderBy({"id"="ASC"})
  102.      */
  103.     private $images;
  104.     /**
  105.      * @var \App\Admin\Modules\Store\Entity\StoreProductDelivery
  106.      *
  107.      * @ORM\OneToMany(targetEntity="App\Admin\Modules\Store\Entity\StoreProductDelivery", mappedBy="product", cascade={"persist"}, orphanRemoval=true)
  108.      * @ORM\OrderBy({"price"="ASC"})
  109.      */
  110.     private $deliveries;
  111.     public function __construct()
  112.     {
  113.         $this->images = new ArrayCollection();
  114.         $this->deliveries = new ArrayCollection();
  115.     }    
  116.     public function getId(): ?string
  117.     {
  118.         return $this->id;
  119.     }
  120.     public function getName(): ?string
  121.     {
  122.         return $this->name;
  123.     }
  124.     public function setName(string $name): self
  125.     {
  126.         $this->name $name;
  127.         return $this;
  128.     }
  129.     public function getDescription(): ?string
  130.     {
  131.         return $this->description;
  132.     }
  133.     public function setDescription(string $description): self
  134.     {
  135.         $this->description $description;
  136.         return $this;
  137.     }
  138.     public function getPosition(): ?int
  139.     {
  140.         return $this->position;
  141.     }
  142.     public function setPosition(int $position): self
  143.     {
  144.         $this->position $position;
  145.         return $this;
  146.     }
  147.     public function getCategory(): ?StoreCategory
  148.     {
  149.         return $this->category;
  150.     }
  151.     public function setCategory(?StoreCategory $category): self
  152.     {
  153.         $this->category $category;
  154.         return $this;
  155.     }
  156.     public function getAddedBy(): ?User
  157.     {
  158.         return $this->addedBy;
  159.     }
  160.     public function setAddedBy(?User $addedBy): self
  161.     {
  162.         $this->addedBy $addedBy;
  163.         return $this;
  164.     }
  165.     public function getPrice(): ?string
  166.     {
  167.         return $this->price;
  168.     }
  169.     public function setPrice(string $price): self
  170.     {
  171.         $this->price $price;
  172.         return $this;
  173.     }
  174.     public function getVat(): ?int
  175.     {
  176.         return $this->vat;
  177.     }
  178.     public function setVat(int $vat): self
  179.     {
  180.         $this->vat $vat;
  181.         return $this;
  182.     }
  183.     public function getWeight(): ?string
  184.     {
  185.         return $this->weight;
  186.     }
  187.     public function setWeight(string $weight): self
  188.     {
  189.         $this->weight $weight;
  190.         return $this;
  191.     }
  192.     public function getLeadTime(): ?int
  193.     {
  194.         return $this->leadTime;
  195.     }
  196.     public function setLeadTime(int $leadTime): self
  197.     {
  198.         $this->leadTime $leadTime;
  199.         return $this;
  200.     }
  201.     public function getImage(): ?string
  202.     {
  203.         return $this->image;
  204.     }
  205.     public function setImage(?string $image): self
  206.     {
  207.         $this->image $image;
  208.         return $this;
  209.     }
  210.     /**
  211.      * @return Collection<int, StoreProductImage>
  212.      */
  213.     public function getImages(): Collection
  214.     {
  215.         return $this->images;
  216.     }
  217.     public function addImage(StoreProductImage $image): self
  218.     {
  219.         if (!$this->images->contains($image)) {
  220.             $this->images->add($image);
  221.             $image->setProduct($this);
  222.         }
  223.         return $this;
  224.     }
  225.     public function removeImage(StoreProductImage $image): self
  226.     {
  227.         if ($this->images->removeElement($image)) {
  228.             // set the owning side to null (unless already changed)
  229.             if ($image->getProduct() === $this) {
  230.                 $image->setProduct(null);
  231.             }
  232.         }
  233.         return $this;
  234.     }
  235.     /**
  236.      * @return Collection<int, StoreProductDelivery>
  237.      */
  238.     public function getDeliveries(): Collection
  239.     {
  240.         return $this->deliveries;
  241.     }
  242.     public function addDelivery(StoreProductDelivery $delivery): self
  243.     {
  244.         if (!$this->deliveries->contains($delivery)) {
  245.             $this->deliveries->add($delivery);
  246.             $delivery->setProduct($this);
  247.         }
  248.         return $this;
  249.     }
  250.     public function removeDelivery(StoreProductDelivery $delivery): self
  251.     {
  252.         if ($this->deliveries->removeElement($delivery)) {
  253.             // set the owning side to null (unless already changed)
  254.             if ($delivery->getProduct() === $this) {
  255.                 $delivery->setProduct(null);
  256.             }
  257.         }
  258.         return $this;
  259.     }
  260. }