src/Entity/BlogKind.php line 12
<?phpnamespace App\Entity;use App\Repository\BlogKindRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\String\Slugger\AsciiSlugger;#[ORM\Entity(repositoryClass: BlogKindRepository::class)]class BlogKind{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 255)]private ?string $name = null;#[ORM\Column(length: 255, unique: true)]private ?string $url = null;#[ORM\ManyToMany(targetEntity: Blog::class, mappedBy: 'kinds')]private Collection $blogs;public function __construct(){$this->blogs = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getName(): ?string{return $this->name;}public function setName(string $name): self{$this->name = $name;$this->setUrl();return $this;}public function getUrl(): ?string{return $this->url;}public function setUrl(): self{$slugger = new AsciiSlugger('cs');$slug = $slugger->slug($this->getName(), '-')->lower();$this->url = $slug->toString();return $this;}/*** @return Collection<int, Blog>*/public function getBlogs(): Collection{return $this->blogs;}public function addBlog(Blog $blog): self{if (!$this->blogs->contains($blog)) {$this->blogs->add($blog);$blog->addKind($this);}return $this;}public function removeBlog(Blog $blog): self{if ($this->blogs->removeElement($blog)) {$blog->removeKind($this);}return $this;}}