src/Entity/Gos/ProductCategory.php line 16

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