<?php
namespace App\Entity;
use App\Repository\ProduitRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ProduitRepository::class)]
class Produit
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string',length: 255)]
private $libelle;
#[ORM\Column(type: 'string',length: 255, nullable: true)]
private $description;
#[ORM\Column(type: 'string',length: 255, nullable: true)]
private $img;
#[ORM\OneToMany(mappedBy: 'produit', targetEntity: Ingredient::class, orphanRemoval: true)]
private $ingredients;
#[ORM\ManyToOne(targetEntity: Categorie::class, inversedBy:'produits')]
private $categorie;
public function __toString()
{
return $this->libelle;
}
public function __construct()
{
$this->ingredients = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getLibelle(): ?string
{
return $this->libelle;
}
public function setLibelle(string $libelle): self
{
$this->libelle = $libelle;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getImg(): ?string
{
return $this->img;
}
public function setImg(?string $img): self
{
$this->img = $img;
return $this;
}
/**
* @return Collection|Ingredient[]
*/
public function getIngredients(): Collection
{
return $this->ingredients;
}
public function addIngredient(Ingredient $ingredient): self
{
if (!$this->ingredients->contains($ingredient)) {
$this->ingredients[] = $ingredient;
$ingredient->setProduit($this);
}
return $this;
}
public function removeIngredient(Ingredient $ingredient): self
{
if ($this->ingredients->removeElement($ingredient)) {
// set the owning side to null (unless already changed)
if ($ingredient->getProduit() === $this) {
$ingredient->setProduit(null);
}
}
return $this;
}
public function getCategorie(): ?Categorie
{
return $this->categorie;
}
public function setCategorie(?Categorie $categorie): self
{
$this->categorie = $categorie;
return $this;
}
}