mirror of
https://forge.chapril.org/tykayn/caisse-bliss
synced 2025-06-20 01:44:42 +02:00
78 lines
1.5 KiB
PHP
78 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Repository\GroupOfProductsRepository;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\DBAL\Types\Types;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
#[ORM\Entity(repositoryClass: GroupOfProductsRepository::class)]
|
|
class GroupOfProducts
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\Column(length: 255)]
|
|
private ?string $name = null;
|
|
|
|
/**
|
|
* @var Collection<int, Product>
|
|
*/
|
|
#[ORM\ManyToMany(targetEntity: Product::class, inversedBy: 'groupOfProducts')]
|
|
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): static
|
|
{
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getProducts(): ?object
|
|
{
|
|
return $this->products;
|
|
}
|
|
|
|
public function setProducts(object $products): static
|
|
{
|
|
$this->products = $products;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function addProduct(Product $product): static
|
|
{
|
|
if (!$this->products->contains($product)) {
|
|
$this->products->add($product);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeProduct(Product $product): static
|
|
{
|
|
$this->products->removeElement($product);
|
|
|
|
return $this;
|
|
}
|
|
}
|