<?php
namespace App\Entity;
use App\Repository\TicketRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: TicketRepository::class)]
class Ticket
{
public const TO_PROCESS = 1;
public const FINISHED = 2;
public const CANCELED = 3;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $title = null;
#[ORM\Column(type: Types::TEXT)]
private ?string $description = null;
#[ORM\Column]
private ?\DateTimeImmutable $addedAt = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $updatedAt = null;
#[ORM\Column]
private ?int $isActive = 1;
#[ORM\OneToMany(mappedBy: 'ticket', targetEntity: Chat::class)]
private Collection $chat;
#[ORM\Column]
private ?int $status = 1;
#[ORM\ManyToOne(inversedBy: 'ticket')]
private ?User $user = null;
public function __construct()
{
$this->setAddedAt(new \DateTimeImmutable());
$this->chat = new ArrayCollection();
}
public function __toString(): string
{
return $this->title;
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
public function getAddedAt(): ?\DateTimeImmutable
{
return $this->addedAt;
}
public function setAddedAt(\DateTimeImmutable $addedAt): self
{
$this->addedAt = $addedAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getIsActive(): ?int
{
return $this->isActive;
}
public function setIsActive(int $isActive): self
{
$this->isActive = $isActive;
return $this;
}
/**
* @return Collection<int, Chat>
*/
public function getChat(): Collection
{
return $this->chat;
}
public function addChat(Chat $chat): self
{
if (!$this->chat->contains($chat)) {
$this->chat->add($chat);
$chat->setTicket($this);
}
return $this;
}
public function removeChat(Chat $chat): self
{
if ($this->chat->removeElement($chat)) {
// set the owning side to null (unless already changed)
if ($chat->getTicket() === $this) {
$chat->setTicket(null);
}
}
return $this;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(int $status): self
{
$this->status = $status;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
}