src/Entity/Categorie.php line 16

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. /**
  8. * Categorie
  9. *
  10. * @ORM\Table(name="Categorie")
  11. * @ORM\Entity(repositoryClass="App\Entity\CategorieRepository")
  12. */
  13. class Categorie
  14. {
  15. public static function createWithId($id)
  16. {
  17. $instance = new self();
  18. $instance->id = $id;
  19. return $instance;
  20. }
  21. /**
  22. * @var integer
  23. *
  24. * @ORM\Column(name="id", type="integer")
  25. * @ORM\Id
  26. * @ORM\GeneratedValue(strategy="AUTO")
  27. */
  28. private $id;
  29. /**
  30. * @var string
  31. *
  32. * @ORM\Column(name="name", type="string", length=255)
  33. */
  34. private $nom;
  35. /**
  36. * @var string
  37. *
  38. * @ORM\Column(name="description", type="string", length=255, nullable=true)
  39. */
  40. private $description;
  41. /**
  42. * @var int
  43. *
  44. * @ORM\Column(name="price", type="integer", nullable=true)
  45. */
  46. private $prix;
  47. /**
  48. * @var int
  49. *
  50. * @ORM\Column(name="credits", type="integer", nullable=true)
  51. */
  52. private $credits;
  53. /**
  54. * @var int
  55. *
  56. * @ORM\Column(name="ordre", type="integer")
  57. */
  58. private $ordre;
  59. /**
  60. * @var Categorie
  61. *
  62. * @ORM\ManyToOne(targetEntity="Categorie")
  63. * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", nullable=true)
  64. */
  65. private $parent;
  66. /**
  67. * @var Categorie
  68. *
  69. * @ORM\ManyToOne(targetEntity="Categorie")
  70. * @ORM\JoinColumn(name="group_id", referencedColumnName="id", nullable=true)
  71. */
  72. private $group;
  73. /**
  74. * @var Page
  75. *
  76. * @ORM\OneToOne(targetEntity="Page")
  77. * @ORM\JoinColumn(name="page_id", referencedColumnName="id", nullable=true)
  78. */
  79. private $page;
  80. /**
  81. * @var ArrayCollection
  82. *
  83. * @ORM\ManyToMany(targetEntity="Prestataire", mappedBy="categories")
  84. */
  85. private $prestataires;
  86. public function __construct()
  87. {
  88. $this->prestataires = new ArrayCollection();
  89. }
  90. /**
  91. * Get id
  92. *
  93. * @return integer
  94. */
  95. public function getId()
  96. {
  97. return $this->id;
  98. }
  99. /**
  100. * Set name
  101. *
  102. * @param string $nom
  103. *
  104. * @return Categorie
  105. */
  106. public function setNom($nom)
  107. {
  108. $this->nom = $nom;
  109. return $this;
  110. }
  111. /**
  112. * Get name
  113. *
  114. * @return string
  115. */
  116. public function getNom()
  117. {
  118. return $this->nom;
  119. }
  120. /**
  121. * @return Categorie
  122. */
  123. public function getParent()
  124. {
  125. return $this->parent;
  126. }
  127. /**
  128. * @param Categorie $parent
  129. */
  130. public function setParent($parent)
  131. {
  132. $this->parent = $parent;
  133. }
  134. /**
  135. * @return Page
  136. */
  137. public function getPage()
  138. {
  139. return $this->page;
  140. }
  141. /**
  142. * @param Page $page
  143. */
  144. public function setPage($page)
  145. {
  146. $this->page = $page;
  147. }
  148. /**
  149. * Add prestataires
  150. *
  151. * @param Prestataire $prestataire
  152. *
  153. * @return Categorie
  154. */
  155. public function addPrestataire(Prestataire $prestataire)
  156. {
  157. $this->prestataires[] = $prestataire;
  158. return $this;
  159. }
  160. /**
  161. * Remove prestataires
  162. *
  163. * @param Prestataire $prestataire
  164. */
  165. public function removePrestataire(Prestataire $prestataire)
  166. {
  167. $this->prestataires->removeElement($prestataire);
  168. }
  169. /**
  170. * Get prestataires
  171. *
  172. * @return Collection
  173. */
  174. public function getPrestataires()
  175. {
  176. return $this->prestataires;
  177. }
  178. /**
  179. * Set price
  180. *
  181. * @param integer $prix
  182. *
  183. * @return Categorie
  184. */
  185. public function setPrix($prix)
  186. {
  187. $this->prix = $prix;
  188. return $this;
  189. }
  190. /**
  191. * Get price
  192. *
  193. * @return integer
  194. */
  195. public function getPrix()
  196. {
  197. return $this->prix;
  198. }
  199. /**
  200. * Set credits
  201. *
  202. * @param integer $credits
  203. *
  204. * @return Categorie
  205. */
  206. public function setCredits($credits)
  207. {
  208. $this->credits = $credits;
  209. return $this;
  210. }
  211. /**
  212. * Get credits
  213. *
  214. * @return integer
  215. */
  216. public function getCredits()
  217. {
  218. return $this->credits;
  219. }
  220. /**
  221. * Set ordre
  222. *
  223. * @param integer $ordre
  224. *
  225. * @return Categorie
  226. */
  227. public function setOrdre($ordre)
  228. {
  229. $this->ordre = $ordre;
  230. return $this;
  231. }
  232. /**
  233. * Get ordre
  234. *
  235. * @return integer
  236. */
  237. public function getOrdre()
  238. {
  239. return $this->ordre;
  240. }
  241. public function __toString()
  242. {
  243. return $this->nom;
  244. }
  245. /**
  246. * Set group
  247. *
  248. * @param Categorie $group
  249. *
  250. * @return Categorie
  251. */
  252. public function setGroup(Categorie $group)
  253. {
  254. $this->group = $group;
  255. return $this;
  256. }
  257. public function updateGroup()
  258. {
  259. if ($this->parent) {
  260. $this->group = $this->parent;
  261. } else {
  262. $this->group = $this;
  263. }
  264. }
  265. /**
  266. * Get group
  267. *
  268. * @return Categorie
  269. */
  270. public function getGroup()
  271. {
  272. return $this->group;
  273. }
  274. public function getHierarchicalName()
  275. {
  276. return ($this->parent ? '   ' : '') . $this->nom;
  277. }
  278. /**
  279. * Set description
  280. *
  281. * @param string $description
  282. * @return Categorie
  283. */
  284. public function setDescription($description)
  285. {
  286. $this->description = $description;
  287. return $this;
  288. }
  289. /**
  290. * Get description
  291. *
  292. * @return string
  293. */
  294. public function getDescription()
  295. {
  296. return $this->description;
  297. }
  298. }