src/Entity/ProductInfo.php line 28

  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(repositoryClass: ProductInfoRepository::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: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(length: 100, nullable: true)]
  35.     private ?string $keyName = null;
  36.     #[Groups(['product:read', 'product:write', 'productInfo:read',  'productInfo:write', 'site_product:read'])]
  37.     #[ORM\Column(length: 255, nullable: true)]
  38.     private ?string $name = null;
  39.     #[Groups(['product:read', 'product:write', 'productInfo:read',  'productInfo:write', 'site_product:read'])]
  40.     #[ORM\Column(type: Types::TEXT, nullable: true)]
  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.     #[Groups(['product:read', 'product:write', 'productInfo:read',  'productInfo:write', 'site_product:read'])]
  46.     #[ORM\Column(nullable: true)]
  47.     private ?array $data = null;
  48.     public function getId(): ?int
  49.     {
  50.         return $this->id;
  51.     }
  52.     public function getProduct(): ?Products
  53.     {
  54.         return $this->product;
  55.     }
  56.     public function setProduct(?Products $product): self
  57.     {
  58.         $this->product = $product;
  59.         return $this;
  60.     }
  61.     public function getKeyName(): ?string
  62.     {
  63.         return $this->keyName;
  64.     }
  65.     public function setKeyName(?string $keyName): self
  66.     {
  67.         $this->keyName = $keyName;
  68.         return $this;
  69.     }
  70.     public function getName(): ?string
  71.     {
  72.         return $this->name;
  73.     }
  74.     public function setName(?string $name): self
  75.     {
  76.         $this->name = $name;
  77.         return $this;
  78.     }
  79.     public function getValue(): ?string
  80.     {
  81.         return $this->value;
  82.     }
  83.     public function setValue(?string $value): self
  84.     {
  85.         $this->value = $value;
  86.         return $this;
  87.     }
  88.     public function getSort(): ?int
  89.     {
  90.         return $this->sort;
  91.     }
  92.     public function setSort(?int $sort): static
  93.     {
  94.         $this->sort = $sort;
  95.         return $this;
  96.     }
  97.     public function getData(): ?array
  98.     {
  99.         return $this->data;
  100.     }
  101.     public function setData(?array $data): static
  102.     {
  103.         $this->data = $data;
  104.         return $this;
  105.     }
  106. }