src/Entity/Categories.php line 11
<?php
namespace App\Entity;
use App\Repository\CategoriesRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CategoriesRepository::class)]
class Categories
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(nullable: true)] // Champs facultatif, car une catégorie peut ne pas avoir d'icône
private ?string $icon = null;
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'categories')]
private ?self $parent = null;
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]
private Collection $categories;
#[ORM\OneToMany(mappedBy: 'categories', targetEntity: Actuality::class)]
private Collection $actualities;
#[ORM\OneToMany(mappedBy: 'categorie', targetEntity: Prestation::class)]
private Collection $prestations;
public function __construct()
{
$this->categories = new ArrayCollection();
$this->actualities = new ArrayCollection();
$this->prestations = 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 getParent(): ?self
{
return $this->parent;
}
public function setParent(?self $parent): self
{
$this->parent = $parent;
return $this;
}
public function getIcon(): ?string
{
return $this->icon;
}
public function setIcon(?string $icon): self
{
$this->icon = $icon;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getCategories(): Collection
{
return $this->categories;
}
public function addCategory(self $category): self
{
if (!$this->categories->contains($category)) {
$this->categories->add($category);
$category->setParent($this);
}
return $this;
}
public function removeCategory(self $category): self
{
if ($this->categories->removeElement($category)) {
// set the owning side to null (unless already changed)
if ($category->getParent() === $this) {
$category->setParent(null);
}
}
return $this;
}
/**
* @return Collection<int, Actuality>
*/
public function getActualities(): Collection
{
return $this->actualities;
}
public function addActuality(Actuality $actuality): self
{
if (!$this->actualities->contains($actuality)) {
$this->actualities->add($actuality);
$actuality->setCategories($this);
}
return $this;
}
public function removeActuality(Actuality $actuality): self
{
if ($this->actualities->removeElement($actuality)) {
// set the owning side to null (unless already changed)
if ($actuality->getCategories() === $this) {
$actuality->setCategories(null);
}
}
return $this;
}
/**
* @return Collection<int, Prestation>
*/
public function getPrestations(): Collection
{
return $this->prestations;
}
public function addPrestation(Prestation $prestation): static
{
if (!$this->prestations->contains($prestation)) {
$this->prestations->add($prestation);
$prestation->setCategorie($this);
}
return $this;
}
public function removePrestation(Prestation $prestation): static
{
if ($this->prestations->removeElement($prestation)) {
// set the owning side to null (unless already changed)
if ($prestation->getCategorie() === $this) {
$prestation->setCategorie(null);
}
}
return $this;
}
}