<?php
namespace App\Entity;
use App\Repository\PrescriberCategoryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\UX\Turbo\Attribute\Broadcast;
#[ORM\Entity(repositoryClass: PrescriberCategoryRepository::class)]
#[Broadcast]
class PrescriberCategory
{
use IdentifiableTrait;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(length: 255)]
private ?string $slug = null;
#[ORM\OneToMany(mappedBy: 'category', targetEntity: Prescriber::class)]
private Collection $prescribers;
public function __construct()
{
$this->prescribers = new ArrayCollection();
}
function __toString(): string
{
return $this->name;
}
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;
}
/**
* @return Collection<int, Prescriber>
*/
public function getPrescribers(): Collection
{
return $this->prescribers;
}
public function addPrescriber(Prescriber $prescriber): self
{
if (!$this->prescribers->contains($prescriber)) {
$this->prescribers->add($prescriber);
$prescriber->setCategory($this);
}
return $this;
}
public function removePrescriber(Prescriber $prescriber): self
{
if ($this->prescribers->removeElement($prescriber)) {
// set the owning side to null (unless already changed)
if ($prescriber->getCategory() === $this) {
$prescriber->setCategory(null);
}
}
return $this;
}
}