src/Entity/Categorie.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CategorieRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClass: CategorieRepository::class)]
  8. class Categorie
  9. {
  10. #[ORM\Id]
  11. #[ORM\GeneratedValue]
  12. #[ORM\Column(type: 'integer')]
  13. private $id;
  14. #[ORM\Column(type: 'string',length: 255)]
  15. private $libelle;
  16. #[ORM\OneToMany(mappedBy: 'categorie', targetEntity: Preparation::class)]
  17. private $preparations;
  18. #[ORM\OneToMany(mappedBy: 'categorie', targetEntity: Produit::class)]
  19. private $produits;
  20. public function __toString()
  21. {
  22. return $this->libelle;
  23. }
  24. public function __construct()
  25. {
  26. $this->preparations = new ArrayCollection();
  27. $this->produits = new ArrayCollection();
  28. }
  29. public function getId(): ?int
  30. {
  31. return $this->id;
  32. }
  33. public function getLibelle(): ?string
  34. {
  35. return $this->libelle;
  36. }
  37. public function setLibelle(string $libelle): self
  38. {
  39. $this->libelle = $libelle;
  40. return $this;
  41. }
  42. /**
  43. * @return Collection|Preparation[]
  44. */
  45. public function getPreparations(): Collection
  46. {
  47. return $this->preparations;
  48. }
  49. public function addPreparation(Preparation $preparation): self
  50. {
  51. if (!$this->preparations->contains($preparation)) {
  52. $this->preparations[] = $preparation;
  53. $preparation->setCategorie($this);
  54. }
  55. return $this;
  56. }
  57. public function removePreparation(Preparation $preparation): self
  58. {
  59. if ($this->preparations->removeElement($preparation)) {
  60. // set the owning side to null (unless already changed)
  61. if ($preparation->getCategorie() === $this) {
  62. $preparation->setCategorie(null);
  63. }
  64. }
  65. return $this;
  66. }
  67. /**
  68. * @return Collection|Produit[]
  69. */
  70. public function getProduits(): Collection
  71. {
  72. return $this->produits;
  73. }
  74. public function addProduit(Produit $produit): self
  75. {
  76. if (!$this->produits->contains($produit)) {
  77. $this->produits[] = $produit;
  78. $produit->setCategorie($this);
  79. }
  80. return $this;
  81. }
  82. public function removeProduit(Produit $produit): self
  83. {
  84. if ($this->produits->removeElement($produit)) {
  85. // set the owning side to null (unless already changed)
  86. if ($produit->getCategorie() === $this) {
  87. $produit->setCategorie(null);
  88. }
  89. }
  90. return $this;
  91. }
  92. }