<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\ProductInfoRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: ProductInfoRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['productInfo:read']],
denormalizationContext: ['groups' => ['productInfo:write']],
order: ['id' => 'DESC'],
)]
#[ApiFilter(
SearchFilter::class,
properties: [
'product.id' => 'exact',
'name' => 'ipartial',
]
)]
class ProductInfo
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['product:read', 'product:write', 'productInfo:read', 'productInfo:write'])]
private ?int $id = null;
#[Groups(['product:read', 'product:write', 'productInfo:read', 'productInfo:write'])]
#[ORM\ManyToOne(inversedBy: 'productInfos')]
private ?Products $product = null;
#[Groups(['product:read', 'product:write', 'productInfo:read', 'productInfo:write'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $keyName = null;
#[Groups(['product:read', 'product:write', 'productInfo:read', 'productInfo:write'])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
#[Groups(['product:read', 'product:write', 'productInfo:read', 'productInfo:write'])]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $value = null;
public function getId(): ?int
{
return $this->id;
}
public function getProduct(): ?Products
{
return $this->product;
}
public function setProduct(?Products $product): self
{
$this->product = $product;
return $this;
}
public function getKeyName(): ?string
{
return $this->keyName;
}
public function setKeyName(?string $keyName): self
{
$this->keyName = $keyName;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getValue(): ?string
{
return $this->value;
}
public function setValue(?string $value): self
{
$this->value = $value;
return $this;
}
}