src/Entity/Shop/Ticket/Ticket.php line 16

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