src/Entity/AttributeItems.php line 22
<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\AttributeItemsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use Symfony\Component\Serializer\Annotation\Groups;
use ApiPlatform\Serializer\Filter\GroupFilter;
#[ORM\Entity(repositoryClass: AttributeItemsRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['attributes_items:read']],
denormalizationContext: ['groups' => ['attributes_items:write']],
order: ['sort' => 'ASC', 'name' => 'ASC'],
)]
#[ApiFilter(SearchFilter::class, properties: [
'name' => 'ipartial',
'categories.id' => 'exact',
'product.id' => 'exact',
'attribute.id' => 'exact',
'product.site_product.id' => 'exact',
'objects.attributeItems.id' => 'exact',
])]
#[ApiFilter(GroupFilter::class, arguments: ['parameterName' => 'g', 'overrideDefaultGroups' => true])]
class AttributeItems
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['attributes_items:read', 'attributes:read', 'attributes:write', 'attributes_items:write', 'product:read', 'site_product:read', 'objects:read', 'cat:read', 'scanning:read'])]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Groups(['attributes_items:read', 'attributes:read', 'attributes:write', 'attributes_items:write', 'product:read', 'site_product:read', 'objects:read', 'cat:read', 'scanning:read'])]
private ?string $name = null;
#[ORM\Column(length: 255)]
#[Groups(['attributes_items:read', 'attributes:read', 'attributes:write', 'attributes_items:write', 'product:read', 'site_product:read', 'objects:read', 'cat:read', 'scanning:read'])]
private ?string $slug = null;
#[Groups(['attributes_items:product', 'attributes_items:write' ])]
#[ORM\ManyToMany(targetEntity: Products::class, inversedBy: 'attributeItems', cascade:['persist', 'remove'])]
private Collection $product;
#[Groups(['attributes_items:read', 'attributes:write', 'attributes_items:write', 'product:read', 'site_product:read', 'objects:read', 'cat:read', 'scanning:read'])]
#[ORM\ManyToOne(inversedBy: 'attributeItems')]
private ?Attributes $attribute = null;
#[Groups(['attributes_items:categories', 'attributes:read', 'attributes:write', 'attributes_items:write', 'objects:read'])]
#[ORM\ManyToMany(targetEntity: Category::class, inversedBy: 'attributeItems')]
private Collection $categories;
#[Groups(['attributes_items:read', 'attributes:read', 'attributes:write', 'attributes_items:write', 'product:read', 'site_product:read', 'objects:read', 'scanning:read'])]
#[ORM\Column(nullable: true)]
private ?int $sort = 0;
#[ORM\ManyToMany(targetEntity: Projects::class, mappedBy: 'attribute_items')]
private Collection $projects;
#[ORM\ManyToMany(targetEntity: Objects::class, mappedBy: 'attributeItems')]
private Collection $objects;
/**
* @var Collection<int, Scannings>
*/
#[ORM\ManyToMany(targetEntity: Scannings::class, mappedBy: 'attributeItems')]
private Collection $scannings;
#[Groups(['attributes_items:read', 'attributes:read', 'attributes:write', 'attributes_items:write', 'product:read', 'site_product:read', 'objects:read', 'cat:read', 'scanning:read'])]
#[ORM\Column(nullable: true)]
private ?bool $main = null;
public function __construct()
{
$this->product = new ArrayCollection();
$this->categories = new ArrayCollection();
$this->projects = new ArrayCollection();
$this->objects = new ArrayCollection();
$this->scannings = 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 getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
/**
* @return Collection<int, Products>
*/
public function getProduct(): Collection
{
return $this->product;
}
public function addProduct(Products $product): self
{
if (!$this->product->contains($product)) {
$this->product->add($product);
}
return $this;
}
public function removeProduct(Products $product): self
{
$this->product->removeElement($product);
return $this;
}
public function getAttribute(): ?Attributes
{
return $this->attribute;
}
public function setAttribute(?Attributes $attribute): self
{
$this->attribute = $attribute;
return $this;
}
/**
* @return Collection<int, Category>
*/
public function getCategories(): Collection
{
return $this->categories;
}
public function addCategory(Category $category): self
{
if (!$this->categories->contains($category)) {
$this->categories->add($category);
}
return $this;
}
public function removeCategory(Category $category): self
{
$this->categories->removeElement($category);
return $this;
}
public function getSort(): ?int
{
return $this->sort;
}
public function setSort(?int $sort): self
{
$this->sort = $sort;
return $this;
}
/**
* @return Collection<int, Projects>
*/
public function getProjects(): Collection
{
return $this->projects;
}
public function addProject(Projects $project): static
{
if (!$this->projects->contains($project)) {
$this->projects->add($project);
$project->addAttributeItem($this);
}
return $this;
}
public function removeProject(Projects $project): static
{
if ($this->projects->removeElement($project)) {
$project->removeAttributeItem($this);
}
return $this;
}
/**
* @return Collection<int, Objects>
*/
public function getObjects(): Collection
{
return $this->objects;
}
public function addObject(Objects $object): static
{
if (!$this->objects->contains($object)) {
$this->objects->add($object);
$object->addAttributeItem($this);
}
return $this;
}
public function removeObject(Objects $object): static
{
if ($this->objects->removeElement($object)) {
$object->removeAttributeItem($this);
}
return $this;
}
/**
* @return Collection<int, Scannings>
*/
public function getScannings(): Collection
{
return $this->scannings;
}
public function addScanning(Scannings $scanning): static
{
if (!$this->scannings->contains($scanning)) {
$this->scannings->add($scanning);
$scanning->addAttributeItem($this);
}
return $this;
}
public function removeScanning(Scannings $scanning): static
{
if ($this->scannings->removeElement($scanning)) {
$scanning->removeAttributeItem($this);
}
return $this;
}
public function isMain(): ?bool
{
return $this->main;
}
public function setMain(?bool $main): static
{
$this->main = $main;
return $this;
}
}