src/Entity/BaseSite/Ticket/Ticket.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\BaseSite\Ticket;
  3. use App\Entity\BaseEntity;
  4. use App\Entity\Generic\User;
  5. use App\Repository\BaseSite\Ticket\TicketRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  10. #[ORM\Entity(repositoryClassTicketRepository::class)]
  11. #[ORM\Table(name'`base_site_ticket`')]
  12. class Ticket extends BaseEntity
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\Column(type'guid'uniquetrue)]
  16.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  17.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  18.     private ?string $id;
  19.     #[ORM\Column(length255)]
  20.     private ?string $title null;
  21.     #[ORM\Column]
  22.     private ?int $priority null;
  23.     #[ORM\ManyToOne(inversedBy'tickets')]
  24.     #[ORM\JoinColumn(nullablefalse)]
  25.     private ?User $creator null;
  26.     #[ORM\OneToMany(mappedBy'ticket'targetEntityTicketMessage::class)]
  27.     private Collection $ticketMessages;
  28.     public function __construct()
  29.     {
  30.         parent::__construct();
  31.         $this->ticketMessages = new ArrayCollection();
  32.     }
  33.     public function getStatus()
  34.     {
  35.         switch ($this->getPriority()){
  36.             case 0:
  37.                 return'کم اهمیت';
  38.                 break;
  39.             case 1:
  40.                 return'معمولی';
  41.                 break;
  42.             case 2:
  43.                 return'اهمیت بالا';
  44.                 break;
  45.             default:
  46.                 return  $this->getPriority();
  47.                 break;
  48.         }
  49.     }
  50.     public function getId(): ?string
  51.     {
  52.         return $this->id;
  53.     }
  54.     public function getTitle(): ?string
  55.     {
  56.         return $this->title;
  57.     }
  58.     public function setTitle(string $title): static
  59.     {
  60.         $this->title $title;
  61.         return $this;
  62.     }
  63.     public function getPriority(): ?int
  64.     {
  65.         return $this->priority;
  66.     }
  67.     public function setPriority(int $priority): static
  68.     {
  69.         $this->priority $priority;
  70.         return $this;
  71.     }
  72.     public function getCreator(): ?User
  73.     {
  74.         return $this->creator;
  75.     }
  76.     public function setCreator(?User $creator): static
  77.     {
  78.         $this->creator $creator;
  79.         return $this;
  80.     }
  81.     /**
  82.      * @return Collection<int, TicketMessage>
  83.      */
  84.     public function getTicketMessages(): Collection
  85.     {
  86.         return $this->ticketMessages;
  87.     }
  88.     public function addTicketMessage(TicketMessage $ticketMessage): static
  89.     {
  90.         if (!$this->ticketMessages->contains($ticketMessage)) {
  91.             $this->ticketMessages->add($ticketMessage);
  92.             $ticketMessage->setTicket($this);
  93.         }
  94.         return $this;
  95.     }
  96.     public function removeTicketMessage(TicketMessage $ticketMessage): static
  97.     {
  98.         if ($this->ticketMessages->removeElement($ticketMessage)) {
  99.             // set the owning side to null (unless already changed)
  100.             if ($ticketMessage->getTicket() === $this) {
  101.                 $ticketMessage->setTicket(null);
  102.             }
  103.         }
  104.         return $this;
  105.     }
  106. }