src/Entity/Category2.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\Category2Repository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Cocur\Slugify\Slugify;
  9. /**
  10.  * @ApiResource()
  11.  * @ORM\Entity(repositoryClass=Category2Repository::class)
  12.  */
  13. class Category2
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=255)
  23.      */
  24.     private $title;
  25.     /**
  26.      * @ORM\Column(type="string", length=255)
  27.      */
  28.     private $slug;
  29.     /**
  30.      * @ORM\OneToMany(targetEntity=Category::class, mappedBy="category2")
  31.      */
  32.     private $categorys;
  33.     /**
  34.      * @ORM\ManyToOne(targetEntity=Category3::class, inversedBy="categorys2")
  35.      */
  36.     private $category3;
  37.     /**
  38.      * @ORM\Column(type="boolean")
  39.      */
  40.     private $is_active;
  41.     public function __construct()
  42.     {
  43.         $this->categorys = new ArrayCollection();
  44.     }
  45.     public function getId(): ?int
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function getTitle(): ?string
  50.     {
  51.         return $this->title;
  52.     }
  53.     public function getSlug()
  54.     {   
  55.         return $this->slug;
  56.     }
  57.     
  58.     public function setSlug(): self
  59.     {
  60.         $Slugify = new Slugify();
  61.         $slug  $Slugify->slugify($this->getTitle());
  62.         $this->slug $slug;
  63.         return $this;
  64.     }
  65.     public function setTitle(string $title): self
  66.     {
  67.         $this->title $title;
  68.         return $this;
  69.     }
  70.     /**
  71.      * @return Collection<int, Category>
  72.      */
  73.     public function getCategorys(): Collection
  74.     {
  75.         return $this->categorys;
  76.     }
  77.     public function addCategory(Category $category): self
  78.     {
  79.         if (!$this->categorys->contains($category)) {
  80.             $this->categorys[] = $category;
  81.             $category->setCategory2($this);
  82.         }
  83.         return $this;
  84.     }
  85.     public function removeCategory(Category $category): self
  86.     {
  87.         if ($this->categorys->removeElement($category)) {
  88.             // set the owning side to null (unless already changed)
  89.             if ($category->getCategory2() === $this) {
  90.                 $category->setCategory2(null);
  91.             }
  92.         }
  93.         return $this;
  94.     }
  95.     public function getCategory3(): ?Category3
  96.     {
  97.         return $this->category3;
  98.     }
  99.     public function setCategory3(?Category3 $category3): self
  100.     {
  101.         $this->category3 $category3;
  102.         return $this;
  103.     }
  104.     public function getIsActive(): ?bool
  105.     {
  106.         return $this->is_active;
  107.     }
  108.     public function setIsActive(bool $is_active): self
  109.     {
  110.         $this->is_active $is_active;
  111.         return $this;
  112.     }
  113. }