src/Entity/ProductInfo.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\ProductInfoRepository;
  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(repositoryClassProductInfoRepository::class)]
  11. #[ApiResource(
  12.     normalizationContext: ['groups' => ['productInfo:read']],
  13.     denormalizationContext: ['groups' => ['productInfo:write']],
  14.     order: ['id' => 'DESC'],
  15. )]
  16. #[ApiFilter(
  17.     SearchFilter::class, 
  18.     properties: [
  19.         'product.id' => 'exact',
  20.         'name' => 'ipartial'
  21.     ]
  22. )]
  23. class ProductInfo
  24. {
  25.     #[ORM\Id]
  26.     #[ORM\GeneratedValue]
  27.     #[ORM\Column]
  28.     #[Groups(['product:read''product:write''productInfo:read',  'productInfo:write'])]
  29.     private ?int $id null;
  30.     #[Groups(['product:read''product:write''productInfo:read',  'productInfo:write'])]
  31.     #[ORM\ManyToOne(inversedBy'productInfos')]
  32.     private ?Products $product null;
  33.     #[Groups(['product:read''product:write''productInfo:read',  'productInfo:write'])]
  34.     #[ORM\Column(length100nullabletrue)]
  35.     private ?string $keyName null;
  36.     #[Groups(['product:read''product:write''productInfo:read',  'productInfo:write'])]
  37.     #[ORM\Column(length255nullabletrue)]
  38.     private ?string $name null;
  39.     #[Groups(['product:read''product:write''productInfo:read',  'productInfo:write'])]
  40.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  41.     private ?string $value null;
  42.     public function getId(): ?int
  43.     {
  44.         return $this->id;
  45.     }
  46.     public function getProduct(): ?Products
  47.     {
  48.         return $this->product;
  49.     }
  50.     public function setProduct(?Products $product): self
  51.     {
  52.         $this->product $product;
  53.         return $this;
  54.     }
  55.     public function getKeyName(): ?string
  56.     {
  57.         return $this->keyName;
  58.     }
  59.     public function setKeyName(?string $keyName): self
  60.     {
  61.         $this->keyName $keyName;
  62.         return $this;
  63.     }
  64.     public function getName(): ?string
  65.     {
  66.         return $this->name;
  67.     }
  68.     public function setName(?string $name): self
  69.     {
  70.         $this->name $name;
  71.         return $this;
  72.     }
  73.     public function getValue(): ?string
  74.     {
  75.         return $this->value;
  76.     }
  77.     public function setValue(?string $value): self
  78.     {
  79.         $this->value $value;
  80.         return $this;
  81.     }
  82. }