src/Flexy/ShopBundle/Entity/Customer/Complaint.php line 20

  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Customer;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  6. use App\Flexy\ShopBundle\Entity\Resource\Agent;
  7. use App\Repository\Flexy\ShopBundle\Entity\Customer\ComplaintRepository;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. #[ORM\Entity(repositoryClassComplaintRepository::class)]
  12. #[ApiResource(
  13.     normalizationContext: ['groups' => ['read']],
  14.     denormalizationContext: ['groups' => ['write']],
  15. )]
  16. #[ApiFilter(SearchFilter::class, properties: ['status' => 'exact','customer'=>'exact'])]
  17. class Complaint
  18. {
  19.     #[ORM\Id]
  20.     #[ORM\GeneratedValue]
  21.     #[ORM\Column]
  22.     #[Groups(['read'])]
  23.     private ?int $id null;
  24.     #[ORM\Column(length255nullabletrue)]
  25.     #[Groups(['read','write'])]
  26.     private ?string $subject null;
  27.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  28.     #[Groups(['read','write'])]
  29.     private ?string $message null;
  30.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  31.     #[Groups(['read','write'])]
  32.     private ?\DateTimeInterface $createdAt null;
  33.     #[ORM\ManyToOne(inversedBy'complaints')]
  34.     #[Groups(['read','write'])]
  35.     private ?Customer $customer null;
  36.     #[ORM\ManyToOne(inversedBy'complaints')]
  37.     #[Groups(['read','write'])]
  38.     private ?ComplaintSubject $complaintSubject null;
  39.     #[Groups(['read','write'])]
  40.     #[ORM\Column(length255nullabletrue)]
  41.     private ?string $status "waiting";
  42.     #[ORM\ManyToOne(inversedBy'complaints')]
  43.     private ?Agent $agent null;
  44.     public function __construct()
  45.     {
  46.         $this->createdAt = new \DateTime();
  47.     }
  48.     public function getId(): ?int
  49.     {
  50.         return $this->id;
  51.     }
  52.     public function getSubject(): ?string
  53.     {
  54.         return $this->subject;
  55.     }
  56.     public function setSubject(?string $subject): self
  57.     {
  58.         $this->subject $subject;
  59.         return $this;
  60.     }
  61.     public function getMessage(): ?string
  62.     {
  63.         return $this->message;
  64.     }
  65.     public function setMessage(?string $message): self
  66.     {
  67.         $this->message $message;
  68.         return $this;
  69.     }
  70.     public function getCreatedAt(): ?\DateTimeInterface
  71.     {
  72.         return $this->createdAt;
  73.     }
  74.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  75.     {
  76.         $this->createdAt $createdAt;
  77.         return $this;
  78.     }
  79.     public function getCustomer(): ?Customer
  80.     {
  81.         return $this->customer;
  82.     }
  83.     public function setCustomer(?Customer $customer): self
  84.     {
  85.         $this->customer $customer;
  86.         return $this;
  87.     }
  88.     public function getComplaintSubject(): ?ComplaintSubject
  89.     {
  90.         return $this->complaintSubject;
  91.     }
  92.     public function setComplaintSubject(?ComplaintSubject $complaintSubject): self
  93.     {
  94.         $this->complaintSubject $complaintSubject;
  95.         return $this;
  96.     }
  97.     public function getStatus(): ?string
  98.     {
  99.         return $this->status;
  100.     }
  101.     public function setStatus(?string $status): self
  102.     {
  103.         $this->status $status;
  104.         return $this;
  105.     }
  106.     public function getAgent(): ?Agent
  107.     {
  108.         return $this->agent;
  109.     }
  110.     public function setAgent(?Agent $agent): self
  111.     {
  112.         $this->agent $agent;
  113.         return $this;
  114.     }
  115.     #[Groups(['read','write'])]
  116.     public function getCreatedAtFormatted(){
  117.         return $this->createdAt->format("d/m/Y H:i");
  118.     }
  119. }