<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\ProductsReletedRepository;
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: ProductsReletedRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['product_releted:read',]],
denormalizationContext: ['groups' => ['product_releted:write']],
order: ['id' => 'ASC'],
)]
#[ApiFilter(
SearchFilter::class,
properties: [
'product.id' => 'exact',
],
)]
class ProductsReleted
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['product:read', 'product_releted:read', 'product_releted:write'])]
private ?int $id = null;
#[Groups(['product_releted:product', 'product_releted:write'])]
#[ORM\ManyToOne(inversedBy: 'productsReleteds')]
private ?Products $product = null;
#[Groups(['product:read', 'product_releted:read', 'product_releted:write'])]
#[ORM\ManyToOne(inversedBy: 'parentProductRelateds')]
private ?Products $relatedProduct = null;
public function getId(): ?int
{
return $this->id;
}
public function getProduct(): ?Products
{
return $this->product;
}
public function setProduct(?Products $product): static
{
$this->product = $product;
return $this;
}
public function getRelatedProduct(): ?Products
{
return $this->relatedProduct;
}
public function setRelatedProduct(?Products $relatedProduct): static
{
$this->relatedProduct = $relatedProduct;
return $this;
}
}