src/Entity/Gos/ProductGroup.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use JMS\Serializer\Annotation as JMS;
  7. /**
  8.  * ProductGroup
  9.  *
  10.  * @ORM\Table(name="product_group")
  11.  * @ORM\Entity(repositoryClass="App\Repository\ProductGroupRepository")
  12.  * @ORM\HasLifecycleCallbacks
  13.  */
  14. class ProductGroup
  15. {
  16.     /**
  17.      * @var int
  18.      *
  19.      * @ORM\Column(name="id", type="integer")
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue(strategy="AUTO")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @var string
  26.      *
  27.      * @ORM\Column(name="name", type="string", length=255, unique=true)
  28.      * @JMS\Groups({"PortalSettings"})
  29.      */
  30.     private $name;
  31.     /**
  32.      * @ORM\OneToMany(targetEntity="App\Entity\Gos\Product", mappedBy="productGroups")
  33.      */
  34.     private $products;
  35.     /**
  36.      * @ORM\Column(type="datetime")
  37.      */
  38.     private $createdAt;
  39.     /**
  40.      * @ORM\Column(type="datetime", nullable=true)
  41.      */
  42.     private $updatedAt;
  43.     /** @ORM\PrePersist() */
  44.     public function prePersist()
  45.     {
  46.         $this->createdAt = new \DateTime();
  47.     }
  48.     /** @ORM\PreUpdate() */
  49.     public function preUpdate()
  50.     {
  51.         $this->updatedAt = new \DateTime();
  52.     }
  53.     public function __toString()
  54.     {
  55.         return (string)$this->name;
  56.     }
  57.     /**
  58.      * Get id
  59.      *
  60.      * @return int
  61.      */
  62.     public function getId()
  63.     {
  64.         return $this->id;
  65.     }
  66.     /**
  67.      * Set createdAt
  68.      *
  69.      * @param \DateTime $createdAt
  70.      *
  71.      * @return ProductGroup
  72.      */
  73.     public function setCreatedAt($createdAt)
  74.     {
  75.         $this->createdAt $createdAt;
  76.         return $this;
  77.     }
  78.     /**
  79.      * Get createdAt
  80.      *
  81.      * @return \DateTime
  82.      */
  83.     public function getCreatedAt()
  84.     {
  85.         return $this->createdAt;
  86.     }
  87.     /**
  88.      * Set updatedAt
  89.      *
  90.      * @param \DateTime $updatedAt
  91.      *
  92.      * @return ProductGroup
  93.      */
  94.     public function setUpdatedAt($updatedAt)
  95.     {
  96.         $this->updatedAt $updatedAt;
  97.         return $this;
  98.     }
  99.     /**
  100.      * Get updatedAt
  101.      *
  102.      * @return \DateTime
  103.      */
  104.     public function getUpdatedAt()
  105.     {
  106.         return $this->updatedAt;
  107.     }
  108.     /**
  109.      * Constructor
  110.      */
  111.     public function __construct()
  112.     {
  113.         $this->products = new \Doctrine\Common\Collections\ArrayCollection();
  114.     }
  115.     /**
  116.      * Add product
  117.      *
  118.      * @param \App\Entity\Gos\Product $product
  119.      *
  120.      * @return ProductGroup
  121.      */
  122.     public function addProduct(\App\Entity\Gos\Product $product)
  123.     {
  124.         $this->products[] = $product;
  125.         return $this;
  126.     }
  127.     /**
  128.      * Remove product
  129.      *
  130.      * @param \App\Entity\Gos\Product $product
  131.      */
  132.     public function removeProduct(\App\Entity\Gos\Product $product)
  133.     {
  134.         $this->products->removeElement($product);
  135.     }
  136.     /**
  137.      * Get products
  138.      *
  139.      * @return \Doctrine\Common\Collections\Collection
  140.      */
  141.     public function getProducts()
  142.     {
  143.         return $this->products;
  144.     }
  145.     /**
  146.      * Set name
  147.      *
  148.      * @param string $name
  149.      *
  150.      * @return ProductGroup
  151.      */
  152.     public function setName($name)
  153.     {
  154.         $this->name $name;
  155.         return $this;
  156.     }
  157.     /**
  158.      * Get name
  159.      *
  160.      * @return string
  161.      */
  162.     public function getName()
  163.     {
  164.         return $this->name;
  165.     }
  166. }