<?php
namespace App\Entity;
use App\Repository\CategoryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CategoryRepository::class)]
class Category
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $nom = null;
#[ORM\Column(type: Types::DECIMAL, precision: 5, scale: 2, nullable: true)]
private ?string $tax = null;
#[ORM\OneToMany(mappedBy: 'category', targetEntity: Produit::class)]
private Collection $produits;
public function __construct()
{
$this->produits = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setNom(string $nom): self
{
$this->nom = $nom;
return $this;
}
public function getTax(): ?string
{
return $this->tax;
}
public function setTax(?string $tax): self
{
$this->tax = $tax;
return $this;
}
/**
* @return Collection<int, Produit>
*/
public function getProduits(): Collection
{
return $this->produits;
}
public function addProduit(Produit $produit): self
{
if (!$this->produits->contains($produit)) {
$this->produits->add($produit);
$produit->setCategory($this);
}
return $this;
}
public function removeProduit(Produit $produit): self
{
if ($this->produits->removeElement($produit)) {
// set the owning side to null (unless already changed)
if ($produit->getCategory() === $this) {
$produit->setCategory(null);
}
}
return $this;
}
public function __toString(): string{
return $this->nom;
}
}