src/Flexy/ShopBundle/Entity/Customer/ComplaintSubject.php line 21

  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\Repository\Flexy\ShopBundle\Entity\Customer\ComplaintSubjectRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\DBAL\Types\Types;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. #[ORM\Entity(repositoryClassComplaintSubjectRepository::class)]
  13. #[ApiResource(
  14.     normalizationContext: ['groups' => ['read']],
  15.     denormalizationContext: ['groups' => ['write']],
  16. )]
  17. #[ApiFilter(SearchFilter::class, properties: ['name' => 'exact','isEnabled'=>'exact'])]
  18. class ComplaintSubject
  19. {
  20.     #[ORM\Id]
  21.     #[ORM\GeneratedValue]
  22.     #[ORM\Column]
  23.     #[Groups(['read'])]
  24.     private ?int $id null;
  25.     #[Groups(['read'])]
  26.     #[ORM\Column(length255)]
  27.     private ?string $name null;
  28.     #[Groups(['read'])]
  29.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  30.     private ?string $description null;
  31.     #[ORM\OneToMany(mappedBy'complaintSubject'targetEntityComplaint::class)]
  32.     private Collection $complaints;
  33.     #[Groups(['read'])]
  34.     #[ORM\Column(nullabletrue)]
  35.     private ?bool $isEnabled null;
  36.     public function __construct()
  37.     {
  38.         $this->complaints = new ArrayCollection();
  39.     }
  40.     public function __toString()
  41.     {
  42.         return (string)$this->getName();
  43.     }
  44.     public function getId(): ?int
  45.     {
  46.         return $this->id;
  47.     }
  48.     public function getName(): ?string
  49.     {
  50.         return $this->name;
  51.     }
  52.     public function setName(string $name): self
  53.     {
  54.         $this->name $name;
  55.         return $this;
  56.     }
  57.     public function getDescription(): ?string
  58.     {
  59.         return $this->description;
  60.     }
  61.     public function setDescription(?string $description): self
  62.     {
  63.         $this->description $description;
  64.         return $this;
  65.     }
  66.     /**
  67.      * @return Collection<int, Complaint>
  68.      */
  69.     public function getComplaints(): Collection
  70.     {
  71.         return $this->complaints;
  72.     }
  73.     public function addComplaint(Complaint $complaint): self
  74.     {
  75.         if (!$this->complaints->contains($complaint)) {
  76.             $this->complaints->add($complaint);
  77.             $complaint->setComplaintSubject($this);
  78.         }
  79.         return $this;
  80.     }
  81.     public function removeComplaint(Complaint $complaint): self
  82.     {
  83.         if ($this->complaints->removeElement($complaint)) {
  84.             // set the owning side to null (unless already changed)
  85.             if ($complaint->getComplaintSubject() === $this) {
  86.                 $complaint->setComplaintSubject(null);
  87.             }
  88.         }
  89.         return $this;
  90.     }
  91.     public function isIsEnabled(): ?bool
  92.     {
  93.         return $this->isEnabled;
  94.     }
  95.     public function setIsEnabled(?bool $isEnabled): self
  96.     {
  97.         $this->isEnabled $isEnabled;
  98.         return $this;
  99.     }
  100. }