<?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', 'site_product:read'])]
private ?int $id = null;
#[Groups(['product:write', 'productInfo:read', 'productInfo:write'])]
#[ORM\ManyToOne(inversedBy: 'productInfos')]
private ?Products $product = null;
#[Groups(['product:read', 'product:write', 'productInfo:read', 'productInfo:write', 'site_product:read'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $keyName = null;
#[Groups(['product:read', 'product:write', 'productInfo:read', 'productInfo:write', 'site_product:read'])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
#[Groups(['product:read', 'product:write', 'productInfo:read', 'productInfo:write', 'site_product:read'])]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $value = null;
#[Groups(['product:read', 'product:write', 'productInfo:read', 'productInfo:write', 'site_product:read'])]
#[ORM\Column(options: ["default" => 0])]
private ?int $sort = 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;
}
public function getSort(): ?int
{
return $this->sort;
}
public function setSort(?int $sort): static
{
$this->sort = $sort;
return $this;
}
}