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.      * @Gedmo\SortablePosition
  63.      * @var string $position
  64.      *
  65.      * @ORM\Column(type="integer", nullable=true)
  66.      */
  67.     protected $position;
  68.     /**
  69.     * @var \App\Entity\Seo $seo
  70.     *
  71.     * @ORM\ManyToOne(targetEntity="App\Entity\Seo", inversedBy="general_category")
  72.     * @ORM\JoinColumn(name="seo_id", referencedColumnName="id")
  73.     */
  74.     private $seo;
  75.     /**
  76.      * @var string $create_at
  77.      *
  78.      * @Gedmo\Timestampable(on="create")
  79.      * @ORM\Column(type="datetime", nullable=true)
  80.      */
  81.     protected $create_at;
  82.     /**
  83.      * @var string $update_at
  84.      *
  85.      * @Gedmo\Timestampable(on="update")
  86.      * @ORM\Column(type="datetime", nullable=true)
  87.      */
  88.     protected $update_at;
  89.     public function __toString(): string
  90.     {
  91.         return $this->getName();
  92.     }
  93.     public function __construct()
  94.     {
  95.         $this->product_categories = new ArrayCollection();
  96.     }
  97.     public function getId(): ?int
  98.     {
  99.         return $this->id;
  100.     }
  101.     public function getName(): ?string
  102.     {
  103.         return $this->name;
  104.     }
  105.     public function setName(?string $name): static
  106.     {
  107.         $this->name $name;
  108.         return $this;
  109.     }
  110.     public function getSlug(): ?string
  111.     {
  112.         return $this->slug;
  113.     }
  114.     public function setSlug(?string $slug): static
  115.     {
  116.         $this->slug $slug;
  117.         return $this;
  118.     }
  119.     public function getCreateAt(): ?\DateTimeInterface
  120.     {
  121.         return $this->create_at;
  122.     }
  123.     public function setCreateAt(?\DateTimeInterface $create_at): static
  124.     {
  125.         $this->create_at $create_at;
  126.         return $this;
  127.     }
  128.     public function getUpdateAt(): ?\DateTimeInterface
  129.     {
  130.         return $this->update_at;
  131.     }
  132.     public function setUpdateAt(?\DateTimeInterface $update_at): static
  133.     {
  134.         $this->update_at $update_at;
  135.         return $this;
  136.     }
  137.     /**
  138.      * @return Collection<int, ProductCategory>
  139.      */
  140.     public function getProductCategories(): Collection
  141.     {
  142.         return $this->product_categories;
  143.     }
  144.     public function addProductCategory(ProductCategory $productCategory): static
  145.     {
  146.         if (!$this->product_categories->contains($productCategory)) {
  147.             $this->product_categories->add($productCategory);
  148.             $productCategory->setGeneralCategory($this);
  149.         }
  150.         return $this;
  151.     }
  152.     public function removeProductCategory(ProductCategory $productCategory): static
  153.     {
  154.         if ($this->product_categories->removeElement($productCategory)) {
  155.             // set the owning side to null (unless already changed)
  156.             if ($productCategory->getGeneralCategory() === $this) {
  157.                 $productCategory->setGeneralCategory(null);
  158.             }
  159.         }
  160.         return $this;
  161.     }
  162.     public function getSeo(): ?Seo
  163.     {
  164.         return $this->seo;
  165.     }
  166.     public function setSeo(?Seo $seo): static
  167.     {
  168.         $this->seo $seo;
  169.         return $this;
  170.     }
  171.     public function getImage(): ?SonataMediaMedia
  172.     {
  173.         return $this->image;
  174.     }
  175.     public function setImage(?SonataMediaMedia $image): static
  176.     {
  177.         $this->image $image;
  178.         return $this;
  179.     }
  180.     public function getImageMobile(): ?SonataMediaMedia
  181.     {
  182.         return $this->image_mobile;
  183.     }
  184.     public function setImageMobile(?SonataMediaMedia $image_mobile): static
  185.     {
  186.         $this->image_mobile $image_mobile;
  187.         return $this;
  188.     }
  189.     public function getImageDesk(): ?SonataMediaMedia
  190.     {
  191.         return $this->image_desk;
  192.     }
  193.     public function setImageDesk(?SonataMediaMedia $image_desk): static
  194.     {
  195.         $this->image_desk $image_desk;
  196.         return $this;
  197.     }
  198.     public function getPosition(): ?int
  199.     {
  200.         return $this->position;
  201.     }
  202.     public function setPosition(?int $position): static
  203.     {
  204.         $this->position $position;
  205.         return $this;
  206.     }
  207. }