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''site_product:read'])]
  29.     private ?int $id null;
  30.     #[Groups(['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''site_product:read'])]
  34.     #[ORM\Column(length100nullabletrue)]
  35.     private ?string $keyName null;
  36.     #[Groups(['product:read''product:write''productInfo:read',  'productInfo:write''site_product:read'])]
  37.     #[ORM\Column(length255nullabletrue)]
  38.     private ?string $name null;
  39.     #[Groups(['product:read''product:write''productInfo:read',  'productInfo:write''site_product:read'])]
  40.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  41.     private ?string $value null;
  42.     #[Groups(['product:read''product:write''productInfo:read',  'productInfo:write''site_product:read'])]
  43.     #[ORM\Column(options: ["default" => 0])]
  44.     private ?int $sort null;
  45.     public function getId(): ?int
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function getProduct(): ?Products
  50.     {
  51.         return $this->product;
  52.     }
  53.     public function setProduct(?Products $product): self
  54.     {
  55.         $this->product $product;
  56.         return $this;
  57.     }
  58.     public function getKeyName(): ?string
  59.     {
  60.         return $this->keyName;
  61.     }
  62.     public function setKeyName(?string $keyName): self
  63.     {
  64.         $this->keyName $keyName;
  65.         return $this;
  66.     }
  67.     public function getName(): ?string
  68.     {
  69.         return $this->name;
  70.     }
  71.     public function setName(?string $name): self
  72.     {
  73.         $this->name $name;
  74.         return $this;
  75.     }
  76.     public function getValue(): ?string
  77.     {
  78.         return $this->value;
  79.     }
  80.     public function setValue(?string $value): self
  81.     {
  82.         $this->value $value;
  83.         return $this;
  84.     }
  85.     public function getSort(): ?int
  86.     {
  87.         return $this->sort;
  88.     }
  89.     public function setSort(?int $sort): static
  90.     {
  91.         $this->sort $sort;
  92.         return $this;
  93.     }
  94. }