src/Entity/Categorie.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CategorieRepository;
  4. use App\Util\Status;
  5. use Cocur\Slugify\Slugify;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. /**
  10. * @ORM\Entity(repositoryClass=CategorieRepository::class)
  11. */
  12. class Categorie
  13. {
  14. /**
  15. * @ORM\Id
  16. * @ORM\GeneratedValue
  17. * @ORM\Column(type="integer")
  18. */
  19. private $id;
  20. /**
  21. * @ORM\Column(type="text")
  22. */
  23. private $nom;
  24. /**
  25. * @ORM\Column(type="integer")
  26. */
  27. private $statut;
  28. /**
  29. * @ORM\Column(type="text", nullable=true)
  30. */
  31. private $notes;
  32. /**
  33. * @ORM\OneToMany(targetEntity=Prestation::class, mappedBy="categorie")
  34. */
  35. private $prestations;
  36. /**
  37. * @ORM\Column(type="text", nullable=true)
  38. */
  39. private $details;
  40. public function __construct()
  41. {
  42. $this->prestations = new ArrayCollection();
  43. }
  44. public function getId(): ?int
  45. {
  46. return $this->id;
  47. }
  48. public function getNom(): ?string
  49. {
  50. return $this->nom;
  51. }
  52. public function setNom(string $nom): self
  53. {
  54. $this->nom = $nom;
  55. return $this;
  56. }
  57. public function getStatut(): ?int
  58. {
  59. return $this->statut;
  60. }
  61. public function setStatut(int $statut): self
  62. {
  63. $this->statut = $statut;
  64. return $this;
  65. }
  66. public function getNotes(): ?string
  67. {
  68. return $this->notes;
  69. }
  70. public function setNotes(?string $notes): self
  71. {
  72. $this->notes = $notes;
  73. return $this;
  74. }
  75. /**
  76. * @return Collection<int, Prestation>
  77. */
  78. public function getPrestations(): Collection
  79. {
  80. return $this->prestations;
  81. }
  82. public function addPrestation(Prestation $prestation): self
  83. {
  84. if (!$this->prestations->contains($prestation)) {
  85. $this->prestations[] = $prestation;
  86. $prestation->setCategorie($this);
  87. }
  88. return $this;
  89. }
  90. public function removePrestation(Prestation $prestation): self
  91. {
  92. if ($this->prestations->removeElement($prestation)) {
  93. // set the owning side to null (unless already changed)
  94. if ($prestation->getCategorie() === $this) {
  95. $prestation->setCategorie(null);
  96. }
  97. }
  98. return $this;
  99. }
  100. public function isValid(): bool{
  101. return $this->getStatut() == Status::VALID;
  102. }
  103. public function getSlug()
  104. {
  105. return (new Slugify())->slugify($this->getNom()) ;
  106. }
  107. public function getDetails(): ?string
  108. {
  109. return $this->details;
  110. }
  111. public function setDetails(?string $details): self
  112. {
  113. $this->details = $details;
  114. return $this;
  115. }
  116. }