src/Entity/Category3.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\Category3Repository;
  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=Category3Repository::class)
  12.  */
  13. class Category3
  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=Category2::class, mappedBy="category3")
  31.      */
  32.     private $categorys2;
  33.     /**
  34.      * @ORM\Column(type="string", length=255, nullable=true)
  35.      */
  36.     private $icon;
  37.     public function __construct()
  38.     {
  39.         $this->categorys2 = new ArrayCollection();
  40.     }
  41.     public function getId(): ?int
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getTitle(): ?string
  46.     {
  47.         return $this->title;
  48.     }
  49.     public function setTitle(string $title): self
  50.     {
  51.         $this->title $title;
  52.         return $this;
  53.     }
  54.     public function setSlug(): self
  55.     {
  56.         $Slugify = new Slugify();
  57.         $slug  $Slugify->slugify($this->getTitle());
  58.         $this->slug $slug;
  59.         return $this;
  60.     }
  61.     public function getSlug()
  62.     {
  63.         return $this->slug;
  64.     }
  65.     /**
  66.      * @return Collection<int, Category2>
  67.      */
  68.     public function getCategorys2(): Collection
  69.     {
  70.         return $this->categorys2;
  71.     }
  72.     public function addCategorys2(Category2 $categorys2): self
  73.     {
  74.         if (!$this->categorys2->contains($categorys2)) {
  75.             $this->categorys2[] = $categorys2;
  76.             $categorys2->setCategory3($this);
  77.         }
  78.         return $this;
  79.     }
  80.     public function removeCategorys2(Category2 $categorys2): self
  81.     {
  82.         if ($this->categorys2->removeElement($categorys2)) {
  83.             // set the owning side to null (unless already changed)
  84.             if ($categorys2->getCategory3() === $this) {
  85.                 $categorys2->setCategory3(null);
  86.             }
  87.         }
  88.         return $this;
  89.     }
  90.     public function getIcon(): ?string
  91.     {
  92.         return $this->icon;
  93.     }
  94.     public function setIcon(?string $icon): self
  95.     {
  96.         $this->icon $icon;
  97.         return $this;
  98.     }
  99. }