<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Table;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\OneToMany;
#[Entity]
#[Table(name: "categorie")]
class Categorie
{
#[Id]
#[GeneratedValue]
#[Column(type: "integer")]
private int $id;
#[Column(type: "string", length: 255)]
private string $nom;
#[OneToMany(mappedBy: "categorie", targetEntity: Prestation::class)]
private Collection $prestations;
#[Column(type: "boolean")]
private bool $deleted = false;
public function __construct()
{
$this->prestations = new ArrayCollection();
}
public function getId(): int
{
return $this->id;
}
public function setId(int $id): void
{
$this->id = $id;
}
public function getNom(): string
{
return $this->nom;
}
public function setNom(string $nom): void
{
$this->nom = $nom;
}
/**
* @return Collection<int, Prestation>
*/
public function getPrestations(): Collection
{
return $this->prestations;
}
public function addPrestation(Prestation $prestation): self
{
if (!$this->prestations->contains($prestation)) {
$this->prestations[] = $prestation;
$prestation->setCategorie($this);
}
return $this;
}
public function removePrestation(Prestation $prestation): self
{
if ($this->prestations->removeElement($prestation)) {
// set the owning side to null (unless already changed)
if ($prestation->getCategorie() === $this) {
$prestation->setCategorie(null);
}
}
return $this;
}
public function setPrestations(Collection $prestations): self
{
$this->prestations = $prestations;
return $this;
}
public function isDeleted(): bool
{
return $this->deleted;
}
public function setDeleted(bool $deleted): void
{
$this->deleted = $deleted;
}
/**
* @return Collection<int, Prestation>
*/
public function getActivePrestations(): Collection
{
return $this->prestations->filter(function(Prestation $prestation) {
return !$prestation->isDeleted();
});
}
/**
* @return Collection<int, Prestation>
*/
public function getAllPrestations(): Collection
{
return $this->prestations;
}
}