<?php

namespace App\Entity;

use App\Repository\GroupeCategorieRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: GroupeCategorieRepository::class)]
class GroupeCategorie
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    #[ORM\Column(length: 255, unique:true)]
    private ?string $nom = null;

    #[ORM\OneToMany(mappedBy: 'groupeCategorie', targetEntity: Categorie::class)]
    private Collection $categories;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $icon_fontawesome = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $image = null;

    public function __construct()
    {
        $this->categories = new ArrayCollection();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getNom(): ?string
    {
        return $this->nom;
    }

    public function setNom(string $nom): static
    {
        $this->nom = $nom;

        return $this;
    }

    /**
     * @return Collection<int, Categorie>
     */
    public function getCategories(): Collection
    {
        return $this->categories;
    }

    public function addCategory(Categorie $category): static
    {
        if (!$this->categories->contains($category)) {
            $this->categories->add($category);
            $category->setGroupeCategorie($this);
        }

        return $this;
    }

    public function removeCategory(Categorie $category): static
    {
        if ($this->categories->removeElement($category)) {
            // set the owning side to null (unless already changed)
            if ($category->getGroupeCategorie() === $this) {
                $category->setGroupeCategorie(null);
            }
        }

        return $this;
    }

    public function getIconFontawesome(): ?string
    {
        return $this->icon_fontawesome;
    }

    public function setIconFontawesome(?string $icon_fontawesome): static
    {
        $this->icon_fontawesome = $icon_fontawesome;

        return $this;
    }

    public function getImage(): ?string
    {
        return $this->image;
    }

    public function setImage(?string $image): static
    {
        $this->image = $image;

        return $this;
    }
}
