<?phpnamespace App\Entity;use App\Repository\CategoryRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Gedmo\Mapping\Annotation as Gedmo;/** * @ORM\Entity(repositoryClass=CategoryRepository::class) */class Category{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255) */ private $name; /** * @ORM\Column(type="string", length=191, unique=true) * @Gedmo\Slug(fields={"name"}) */ private $slug; /** * @ORM\Column(type="text", nullable=true) */ private $description; /** * @ORM\Column(type="string", length=50, nullable=true) */ private $color; /** * @ORM\Column(type="string", length=50, nullable=true) */ private $icon; /** * @ORM\Column(type="integer") */ private $position = 0; /** * @ORM\Column(type="boolean") */ private $isActive = true; /** * @ORM\OneToMany(targetEntity=Article::class, mappedBy="category") */ private $articles; /** * @ORM\Column(type="datetime") * @Gedmo\Timestampable(on="create") */ private $createdAt; /** * @ORM\Column(type="datetime") * @Gedmo\Timestampable(on="update") */ private $updatedAt; public function __construct() { $this->articles = 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; return $this; } public function getSlug(): ?string { return $this->slug; } public function setSlug(string $slug): self { $this->slug = $slug; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(?string $description): self { $this->description = $description; return $this; } public function getColor(): ?string { return $this->color; } public function setColor(?string $color): self { $this->color = $color; return $this; } public function getIcon(): ?string { return $this->icon; } public function setIcon(?string $icon): self { $this->icon = $icon; return $this; } public function getPosition(): ?int { return $this->position; } public function setPosition(int $position): self { $this->position = $position; return $this; } public function getIsActive(): ?bool { return $this->isActive; } public function setIsActive(bool $isActive): self { $this->isActive = $isActive; return $this; } /** * @return Collection|Article[] */ public function getArticles(): Collection { return $this->articles; } public function addArticle(Article $article): self { if (!$this->articles->contains($article)) { $this->articles[] = $article; $article->setCategory($this); } return $this; } public function removeArticle(Article $article): self { if ($this->articles->removeElement($article)) { if ($article->getCategory() === $this) { $article->setCategory(null); } } return $this; } public function getCreatedAt(): ?\DateTimeInterface { return $this->createdAt; } public function setCreatedAt(\DateTimeInterface $createdAt): self { $this->createdAt = $createdAt; return $this; } public function getUpdatedAt(): ?\DateTimeInterface { return $this->updatedAt; } public function setUpdatedAt(\DateTimeInterface $updatedAt): self { $this->updatedAt = $updatedAt; return $this; } public function __toString(): string { return $this->name ?? ''; }}