src/Entity/Comments.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\CommentsRepository;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use ApiPlatform\Metadata\ApiFilter;
  8. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. #[ORM\Entity(repositoryClassCommentsRepository::class)]
  11. #[ApiResource(
  12.     normalizationContext: ['groups' => ['comment:read']],
  13.     denormalizationContext: ['groups' => ['comment:write']],
  14. )]
  15. #[ApiFilter(SearchFilter::class, properties: [ 
  16.     'product.id' => 'exact',
  17.     'show' => 'exact',
  18. ])]
  19. class Comments
  20. {
  21.     #[ORM\Id]
  22.     #[ORM\GeneratedValue]
  23.     #[ORM\Column]
  24.     #[Groups(['comment:read''comment:write'])]
  25.     private ?int $id null;
  26.     #[Groups(['comment:read''comment:write'])]
  27.     #[ORM\ManyToOne(inversedBy'comments')]
  28.     private ?Products $product null;
  29.     #[Groups(['comment:read''comment:write'])]
  30.     #[ORM\ManyToOne(inversedBy'comments')]
  31.     private ?User $users null;
  32.     #[Groups(['comment:read''comment:write'])]
  33.     #[ORM\Column(typeTypes::TEXT)]
  34.     private ?string $content null;
  35.     #[Groups(['comment:read''comment:write'])]
  36.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  37.     private ?\DateTimeInterface $date null;
  38.     #[Groups(['comment:read''comment:write'])]
  39.     #[ORM\Column(nullabletrue)]
  40.     private ?bool $show null;
  41.     public function getId(): ?int
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getProduct(): ?Products
  46.     {
  47.         return $this->product;
  48.     }
  49.     public function setProduct(?Products $product): static
  50.     {
  51.         $this->product $product;
  52.         return $this;
  53.     }
  54.     public function getUsers(): ?User
  55.     {
  56.         return $this->users;
  57.     }
  58.     public function setUsers(?User $users): static
  59.     {
  60.         $this->users $users;
  61.         return $this;
  62.     }
  63.     public function getContent(): ?string
  64.     {
  65.         return $this->content;
  66.     }
  67.     public function setContent(string $content): static
  68.     {
  69.         $this->content $content;
  70.         return $this;
  71.     }
  72.     public function getDate(): ?\DateTimeInterface
  73.     {
  74.         return $this->date;
  75.     }
  76.     public function setDate(?\DateTimeInterface $date): static
  77.     {
  78.         $this->date $date;
  79.         return $this;
  80.     }
  81.     public function isShow(): ?bool
  82.     {
  83.         return $this->show;
  84.     }
  85.     public function setShow(?bool $show): static
  86.     {
  87.         $this->show $show;
  88.         return $this;
  89.     }
  90. }