<?php
namespace App\Entity;
use App\Repository\LogHistoryCategoryRepository;
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: LogHistoryCategoryRepository::class)]
#[Broadcast]
class LogHistoryCategory
{
use IdentifiableTrait;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(length: 255)]
private ?string $slug = null;
#[ORM\OneToMany(mappedBy: 'category', targetEntity: LogHistory::class)]
private Collection $logHistories;
public function __construct()
{
$this->logHistories = 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;
}
/**
* @return Collection<int, LogHistory>
*/
public function getLogHistories(): Collection
{
return $this->logHistories;
}
public function addLogHistory(LogHistory $logHistory): self
{
if (!$this->logHistories->contains($logHistory)) {
$this->logHistories->add($logHistory);
$logHistory->setCategory($this);
}
return $this;
}
public function removeLogHistory(LogHistory $logHistory): self
{
if ($this->logHistories->removeElement($logHistory)) {
// set the owning side to null (unless already changed)
if ($logHistory->getCategory() === $this) {
$logHistory->setCategory(null);
}
}
return $this;
}
}