<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\LanguagesRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: LanguagesRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['language:read']],
denormalizationContext: ['groups' => ['language:write']],
order: ['id' => 'DESC'],
)]
class Languages
{
#[Groups(['language:read', 'language:write', 'product:read', 'product:write', 'cat:read', 'order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'load_invoice:read', 'user_like:read', 'order_product:read', 'attributes_items:read', 'attributes:read', 'cat:read','product_storage_balance:read'])]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[Groups(['language:read', 'language:write', 'product:read', 'product:write', 'cat:read', 'order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'load_invoice:read', 'user_like:read', 'order_product:read', 'attributes_items:read', 'attributes:read', 'cat:read','product_storage_balance:read'])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
#[Groups(['language:read', 'language:write', 'product:read', 'product:write', 'cat:read', 'order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'load_invoice:read', 'user_like:read', 'order_product:read', 'attributes_items:read', 'attributes:read', 'cat:read','product_storage_balance:read'])]
#[ORM\Column(length: 10, nullable: true)]
private ?string $key = null;
#[Groups(['language:read', 'language:write', 'product:write', 'cat:read', 'order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'user_like:read', 'order_product:read', 'attributes_items:read', 'attributes:read', 'cat:read','product_storage_balance:read'])]
#[ORM\OneToMany(mappedBy: 'language', targetEntity: Products::class)]
private Collection $products;
public function __construct()
{
$this->products = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getKey(): ?string
{
return $this->key;
}
public function setKey(?string $key): self
{
$this->key = $key;
return $this;
}
/**
* @return Collection<int, Products>
*/
public function getProducts(): Collection
{
return $this->products;
}
public function addProduct(Products $product): self
{
if (!$this->products->contains($product)) {
$this->products->add($product);
$product->setLanguage($this);
}
return $this;
}
public function removeProduct(Products $product): self
{
if ($this->products->removeElement($product)) {
// set the owning side to null (unless already changed)
if ($product->getLanguage() === $this) {
$product->setLanguage(null);
}
}
return $this;
}
}