<?php
namespace App\Entity;
use App\Repository\PriorityRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity(repositoryClass: PriorityRepository::class)]
class Priority
{
#[ORM\Id]
#[ORM\Column(type:"string", length:36)]
private ?string $id = null;
#[ORM\Column(type:"text")]
private ?string $name = null;
#[ORM\OneToMany(mappedBy: 'priority', targetEntity: Ticket::class)]
private Collection $tickets;
public function __construct($name)
{
$this->id = Uuid::v4()->toRfc4122();
$this->name = $name;
$this->tickets = new ArrayCollection();
}
public function getId(): ?string
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection<int, Ticket>
*/
public function getTickets(): Collection
{
return $this->tickets;
}
public function addTicket(Ticket $ticket): self
{
if (!$this->tickets->contains($ticket)) {
$this->tickets->add($ticket);
$ticket->setPriority($this);
}
return $this;
}
public function removeTicket(Ticket $ticket): self
{
if ($this->tickets->removeElement($ticket)) {
// set the owning side to null (unless already changed)
if ($ticket->getPriority() === $this) {
$ticket->setPriority(null);
}
}
return $this;
}
}