src/Entity/BlogCategory.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BlogCategoryRepository;
  4. use App\Traits\CommonTrt;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=BlogCategoryRepository::class)
  10.  */
  11. class BlogCategory
  12. {
  13.     use CommonTrt;
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="string", length=255)
  22.      */
  23.     private $name;
  24.     /**
  25.      * @ORM\Column(type="string", length=255)
  26.      */
  27.     private $slug;
  28.     /**
  29.      * @ORM\Column(type="text", nullable=true)
  30.      */
  31.     private $description;
  32.     /**
  33.      * @ORM\Column(type="boolean")
  34.      */
  35.     private $isActive;
  36.     /**
  37.      * @ORM\OneToMany(targetEntity=Blog::class, mappedBy="category")
  38.      */
  39.     private $blog;
  40.     public function __construct()
  41.     {
  42.         $this->blogs = new ArrayCollection();
  43.         $this->blog = new ArrayCollection();
  44.     }
  45.     public function getId(): ?int
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function getName(): ?string
  50.     {
  51.         return $this->name;
  52.     }
  53.     public function setName(string $name): self
  54.     {
  55.         $this->name = $name;
  56.         return $this;
  57.     }
  58.     public function getSlug(): ?string
  59.     {
  60.         return $this->slug;
  61.     }
  62.     public function setSlug(string $slug): self
  63.     {
  64.         $this->slug = $slug;
  65.         return $this;
  66.     }
  67.     public function getDescription(): ?string
  68.     {
  69.         return $this->description;
  70.     }
  71.     public function setDescription(?string $description): self
  72.     {
  73.         $this->description = $description;
  74.         return $this;
  75.     }
  76.     public function isIsActive(): ?bool
  77.     {
  78.         return $this->isActive;
  79.     }
  80.     public function setIsActive(bool $isActive): self
  81.     {
  82.         $this->isActive = $isActive;
  83.         return $this;
  84.     }
  85.     /**
  86.      * @return Collection<int, Blog>
  87.      */
  88.     public function getBlogs(): Collection
  89.     {
  90.         return $this->blogs;
  91.     }
  92.     public function addBlog(Blog $blog): self
  93.     {
  94.         if (!$this->blogs->contains($blog)) {
  95.             $this->blogs[] = $blog;
  96.             $blog->addCategory($this);
  97.         }
  98.         return $this;
  99.     }
  100.     public function removeBlog(Blog $blog): self
  101.     {
  102.         if ($this->blogs->removeElement($blog)) {
  103.             $blog->removeCategory($this);
  104.         }
  105.         return $this;
  106.     }
  107.     /**
  108.      * @return Collection<int, Blog>
  109.      */
  110.     public function getBlog(): Collection
  111.     {
  112.         return $this->blog;
  113.     }
  114. }