src/Entity/Departement.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use App\Entity\Prestataire;
  7. use App\Misc\StringUtils;
  8. /**
  9. * Departement
  10. *
  11. * @ORM\Table(name="Departement")
  12. * @ORM\Entity(repositoryClass="App\Entity\DepartementRepository")
  13. */
  14. class Departement
  15. {
  16. /**
  17. * @var integer
  18. *
  19. * @ORM\Column(name="id", type="integer")
  20. * @ORM\Id
  21. * @ORM\GeneratedValue(strategy="AUTO")
  22. */
  23. private $id;
  24. /**
  25. * @var string
  26. *
  27. * @ORM\Column(name="code", type="string", length=10)
  28. */
  29. private $code;
  30. /**
  31. * @var string
  32. *
  33. * @ORM\Column(name="name", type="string", length=60)
  34. */
  35. private $nom;
  36. /**
  37. * @var string
  38. *
  39. * @ORM\Column(name="slug", type="string", length=255)
  40. */
  41. private $slug;
  42. /**
  43. * @var Region
  44. *
  45. * @ORM\ManyToOne(targetEntity="Region")
  46. * @ORM\JoinColumn(name="region_id", referencedColumnName="id", nullable=true)
  47. */
  48. private $region;
  49. /**
  50. * @var ArrayCollection
  51. *
  52. * @ORM\ManyToMany(targetEntity="Prestataire", mappedBy="departements")
  53. */
  54. private $prestataires;
  55. public function __construct()
  56. {
  57. $this->prestataires = new ArrayCollection();
  58. }
  59. /**
  60. * Get id
  61. *
  62. * @return integer
  63. */
  64. public function getId()
  65. {
  66. return $this->id;
  67. }
  68. /**
  69. * Set code
  70. *
  71. * @param string $code
  72. *
  73. * @return Departement
  74. */
  75. public function setCode($code)
  76. {
  77. $this->code = $code;
  78. return $this;
  79. }
  80. /**
  81. * Get code
  82. *
  83. * @return string
  84. */
  85. public function getCode()
  86. {
  87. return $this->code;
  88. }
  89. /**
  90. * @param string $nom
  91. *
  92. * @return Departement
  93. */
  94. public function setNom($nom)
  95. {
  96. $this->nom = $nom;
  97. return $this;
  98. }
  99. /**
  100. * @return string
  101. */
  102. public function getNom()
  103. {
  104. return $this->nom;
  105. }
  106. /**
  107. * @param string $slug
  108. *
  109. * @return Departement
  110. */
  111. public function setSlug($slug): self
  112. {
  113. $this->slug = StringUtils::sanitizeString($slug);
  114. return $this;
  115. }
  116. /**
  117. * @return string
  118. */
  119. public function getSlug()
  120. {
  121. return StringUtils::sanitizeString($this->slug);
  122. }
  123. /**
  124. * @return Region
  125. */
  126. public function getRegion()
  127. {
  128. return $this->region;
  129. }
  130. /**
  131. * @param Region $region
  132. */
  133. public function setRegion($region)
  134. {
  135. $this->region = $region;
  136. }
  137. /**
  138. * Add prestataires
  139. *
  140. * @param Prestataire $prestataire
  141. *
  142. * @return Departement
  143. */
  144. public function addPrestataire(Prestataire $prestataire)
  145. {
  146. $this->prestataires[] = $prestataire;
  147. return $this;
  148. }
  149. /**
  150. * Remove prestataires
  151. *
  152. * @param Prestataire $prestataire
  153. */
  154. public function removePrestataire(Prestataire $prestataire)
  155. {
  156. $this->prestataires->removeElement($prestataire);
  157. }
  158. /**
  159. * Get prestataires
  160. *
  161. * @return Collection
  162. */
  163. public function getPrestataires()
  164. {
  165. return $this->prestataires;
  166. }
  167. public function __toString()
  168. {
  169. return $this->code .' – '. $this->getNom();
  170. }
  171. }