src/Entity/GeneralCategory.php line 17

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\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. //use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. /**
  11.  * @ORM\Entity
  12.  * @ORM\Table(name="general_category")
  13.  */
  14. class GeneralCategory
  15. {
  16.     /**
  17.     * @ORM\Id
  18.     * @ORM\Column(type="integer")
  19.     * @ORM\GeneratedValue(strategy="AUTO")
  20.     */
  21.     protected $id;
  22.     /**
  23.     * @var string $name
  24.     *
  25.     * @ORM\Column(type="string", nullable=true)
  26.     */
  27.     protected $name;
  28.     /**
  29.      * @var string $slug
  30.      * @Gedmo\Slug(fields={"name"}, updatable=true, unique=true)
  31.      *
  32.      * @ORM\Column(type="string", nullable=true)
  33.      */
  34.     protected $slug;
  35.     
  36.     /**
  37.     * @var string $image
  38.     *
  39.     * @ORM\ManyToOne(targetEntity="App\Entity\SonataMediaMedia", cascade = {"persist"})
  40.     * @ORM\JoinColumn(name="image_id", referencedColumnName="id", onDelete="SET NULL")
  41.     */
  42.     protected $image;
  43.     /**
  44.     * @var string $image_desk
  45.     *
  46.     * @ORM\ManyToOne(targetEntity="App\Entity\SonataMediaMedia", cascade = {"persist"})
  47.     * @ORM\JoinColumn(name="image_desk_id", referencedColumnName="id", onDelete="SET NULL")
  48.     */
  49.     protected $image_desk;
  50.     /**
  51.     * @var string $image_mobile
  52.     *
  53.     * @ORM\ManyToOne(targetEntity="App\Entity\SonataMediaMedia", cascade = {"persist"})
  54.     * @ORM\JoinColumn(name="image_mobile_id", referencedColumnName="id", onDelete="SET NULL")
  55.     */
  56.     protected $image_mobile;
  57.     /**
  58.     * @ORM\OneToMany(targetEntity = "App\Entity\ProductCategory", mappedBy="general_category")
  59.     */
  60.     protected $product_categories;
  61.     /**
  62.     * @var \App\Entity\Seo $seo
  63.     *
  64.     * @ORM\ManyToOne(targetEntity="App\Entity\Seo", inversedBy="general_category")
  65.     * @ORM\JoinColumn(name="seo_id", referencedColumnName="id")
  66.     */
  67.     private $seo;
  68.     /**
  69.      * @var string $create_at
  70.      *
  71.      * @Gedmo\Timestampable(on="create")
  72.      * @ORM\Column(type="datetime", nullable=true)
  73.      */
  74.     protected $create_at;
  75.     /**
  76.      * @var string $update_at
  77.      *
  78.      * @Gedmo\Timestampable(on="update")
  79.      * @ORM\Column(type="datetime", nullable=true)
  80.      */
  81.     protected $update_at;
  82.     public function __toString(): string
  83.     {
  84.         return $this->getName();
  85.     }
  86.     public function __construct()
  87.     {
  88.         $this->product_categories = new ArrayCollection();
  89.     }
  90.     public function getId(): ?int
  91.     {
  92.         return $this->id;
  93.     }
  94.     public function getName(): ?string
  95.     {
  96.         return $this->name;
  97.     }
  98.     public function setName(?string $name): static
  99.     {
  100.         $this->name $name;
  101.         return $this;
  102.     }
  103.     public function getSlug(): ?string
  104.     {
  105.         return $this->slug;
  106.     }
  107.     public function setSlug(?string $slug): static
  108.     {
  109.         $this->slug $slug;
  110.         return $this;
  111.     }
  112.     public function getCreateAt(): ?\DateTimeInterface
  113.     {
  114.         return $this->create_at;
  115.     }
  116.     public function setCreateAt(?\DateTimeInterface $create_at): static
  117.     {
  118.         $this->create_at $create_at;
  119.         return $this;
  120.     }
  121.     public function getUpdateAt(): ?\DateTimeInterface
  122.     {
  123.         return $this->update_at;
  124.     }
  125.     public function setUpdateAt(?\DateTimeInterface $update_at): static
  126.     {
  127.         $this->update_at $update_at;
  128.         return $this;
  129.     }
  130.     /**
  131.      * @return Collection<int, ProductCategory>
  132.      */
  133.     public function getProductCategories(): Collection
  134.     {
  135.         return $this->product_categories;
  136.     }
  137.     public function addProductCategory(ProductCategory $productCategory): static
  138.     {
  139.         if (!$this->product_categories->contains($productCategory)) {
  140.             $this->product_categories->add($productCategory);
  141.             $productCategory->setGeneralCategory($this);
  142.         }
  143.         return $this;
  144.     }
  145.     public function removeProductCategory(ProductCategory $productCategory): static
  146.     {
  147.         if ($this->product_categories->removeElement($productCategory)) {
  148.             // set the owning side to null (unless already changed)
  149.             if ($productCategory->getGeneralCategory() === $this) {
  150.                 $productCategory->setGeneralCategory(null);
  151.             }
  152.         }
  153.         return $this;
  154.     }
  155.     public function getSeo(): ?Seo
  156.     {
  157.         return $this->seo;
  158.     }
  159.     public function setSeo(?Seo $seo): static
  160.     {
  161.         $this->seo $seo;
  162.         return $this;
  163.     }
  164.     public function getImage(): ?SonataMediaMedia
  165.     {
  166.         return $this->image;
  167.     }
  168.     public function setImage(?SonataMediaMedia $image): static
  169.     {
  170.         $this->image $image;
  171.         return $this;
  172.     }
  173.     public function getImageMobile(): ?SonataMediaMedia
  174.     {
  175.         return $this->image_mobile;
  176.     }
  177.     public function setImageMobile(?SonataMediaMedia $image_mobile): static
  178.     {
  179.         $this->image_mobile $image_mobile;
  180.         return $this;
  181.     }
  182.     public function getImageDesk(): ?SonataMediaMedia
  183.     {
  184.         return $this->image_desk;
  185.     }
  186.     public function setImageDesk(?SonataMediaMedia $image_desk): static
  187.     {
  188.         $this->image_desk $image_desk;
  189.         return $this;
  190.     }
  191. }