src/Entity/ProductsReleted.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\ProductsReletedRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use ApiPlatform\Metadata\ApiFilter;
  7. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. #[ORM\Entity(repositoryClassProductsReletedRepository::class)]
  10. #[ApiResource(
  11.     normalizationContext: ['groups' => ['product_releted:read',]],
  12.     denormalizationContext: ['groups' => ['product_releted:write']],
  13.     order: ['id' => 'ASC'],
  14. )]
  15. #[ApiFilter(
  16.     SearchFilter::class, 
  17.     properties: [
  18.         'product.id' => 'exact',
  19.     ],
  20. )]
  21. class ProductsReleted
  22. {
  23.     #[ORM\Id]
  24.     #[ORM\GeneratedValue]
  25.     #[ORM\Column]
  26.     #[Groups(['product:read''product_releted:read''product_releted:write'])]
  27.     private ?int $id null;
  28.     #[Groups(['product_releted:product''product_releted:write'])]
  29.     #[ORM\ManyToOne(inversedBy'productsReleteds')]
  30.     private ?Products $product null;
  31.     #[Groups(['product:read''product_releted:read''product_releted:write'])]
  32.     #[ORM\ManyToOne(inversedBy'parentProductRelateds')]
  33.     private ?Products $relatedProduct null;
  34.     public function getId(): ?int
  35.     {
  36.         return $this->id;
  37.     }
  38.     public function getProduct(): ?Products
  39.     {
  40.         return $this->product;
  41.     }
  42.     public function setProduct(?Products $product): static
  43.     {
  44.         $this->product $product;
  45.         return $this;
  46.     }
  47.     public function getRelatedProduct(): ?Products
  48.     {
  49.         return $this->relatedProduct;
  50.     }
  51.     public function setRelatedProduct(?Products $relatedProduct): static
  52.     {
  53.         $this->relatedProduct $relatedProduct;
  54.         return $this;
  55.     }
  56. }