src/Entity/Child.php line 12

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. /**
  7. * @ORM\Entity(repositoryClass="App\Repository\ChildRepository")
  8. */
  9. class Child
  10. {
  11. /**
  12. * @ORM\Id()
  13. * @ORM\GeneratedValue()
  14. * @ORM\Column(type="integer")
  15. */
  16. private $id;
  17. /**
  18. * @ORM\Column(type="string", length=100)
  19. */
  20. private $firstName;
  21. /**
  22. * @ORM\Column(type="string", length=100)
  23. */
  24. private $lastName;
  25. /**
  26. * @ORM\Column(type="datetime", nullable=true)
  27. */
  28. private $birthDate;
  29. /**
  30. * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="children")
  31. * @ORM\JoinColumn(nullable=false)
  32. */
  33. private $parent;
  34. /**
  35. * @ORM\ManyToOne(targetEntity="App\Entity\Gender", inversedBy="children")
  36. * @ORM\JoinColumn(nullable=false)
  37. */
  38. private $gender;
  39. /**
  40. * @ORM\OneToMany(targetEntity="App\Entity\SubscriptionOrder", mappedBy="participant")
  41. */
  42. private $subscriptionOrders;
  43. /**
  44. * @ORM\Column(type="string", length=255, nullable=true)
  45. */
  46. private $forumUrl;
  47. /**
  48. * @ORM\OneToMany(targetEntity="App\Entity\SessionOrder", mappedBy="participant")
  49. */
  50. private $sessionOrders;
  51. /**
  52. * @ORM\OneToMany(targetEntity="App\Entity\VideoCoursesRegistration", mappedBy="participant")
  53. */
  54. private $videoCoursesRegistrations;
  55. /**
  56. * @ORM\OneToMany(targetEntity="App\Entity\TicketOrder", mappedBy="participant")
  57. */
  58. private $ticketOrders;
  59. /**
  60. * @ORM\OneToMany(targetEntity=UserPlacementTest::class, mappedBy="participant")
  61. */
  62. private $userPlacementTests;
  63. /**
  64. * @ORM\OneToMany(targetEntity=Exam::class, mappedBy="student")
  65. */
  66. private $exams;
  67. /**
  68. * @ORM\OneToMany(targetEntity=TrainingReport::class, mappedBy="participant")
  69. */
  70. private $trainingReports;
  71. /**
  72. * @ORM\Column(type="boolean", nullable=true)
  73. */
  74. private $isChild;
  75. /**
  76. * @ORM\Column(type="boolean", nullable=true)
  77. */
  78. private $isTeen;
  79. /**
  80. * @ORM\Column(type="boolean", nullable=true)
  81. */
  82. private $isAdult;
  83. public function __construct()
  84. {
  85. $this->subscriptionOrders = new ArrayCollection();
  86. $this->sessionOrders = new ArrayCollection();
  87. $this->videoCoursesRegistrations = new ArrayCollection();
  88. $this->ticketOrders = new ArrayCollection();
  89. $this->userPlacementTests = new ArrayCollection();
  90. $this->exams = new ArrayCollection();
  91. $this->trainingReports = new ArrayCollection();
  92. }
  93. public function getId(): ?int
  94. {
  95. return $this->id;
  96. }
  97. public function getAge()
  98. {
  99. $currentDate = new \DateTimeImmutable();
  100. $age = $currentDate->diff($this->birthDate);
  101. return $age->y;
  102. }
  103. public function getFirstName(): ?string
  104. {
  105. return $this->firstName;
  106. }
  107. public function setFirstName(string $firstName): self
  108. {
  109. $this->firstName = $firstName;
  110. return $this;
  111. }
  112. public function getFullname(){
  113. return trim($this->getFirstname().' '.$this->getLastname());
  114. }
  115. public function getLastName(): ?string
  116. {
  117. return $this->lastName;
  118. }
  119. public function setLastName(string $lastName): self
  120. {
  121. $this->lastName = $lastName;
  122. return $this;
  123. }
  124. public function getBirthDate(): ?\DateTimeInterface
  125. {
  126. return $this->birthDate;
  127. }
  128. public function setBirthDate(\DateTimeInterface $birthDate): self
  129. {
  130. $this->birthDate = $birthDate;
  131. return $this;
  132. }
  133. public function getParent(): ?User
  134. {
  135. return $this->parent;
  136. }
  137. public function setParent(?User $parent): self
  138. {
  139. $this->parent = $parent;
  140. return $this;
  141. }
  142. public function getGender(): ?Gender
  143. {
  144. return $this->gender;
  145. }
  146. public function setGender(?Gender $gender): self
  147. {
  148. $this->gender = $gender;
  149. return $this;
  150. }
  151. /**
  152. * @return Collection|SubscriptionOrder[]
  153. */
  154. public function getSubscriptionOrders(): Collection
  155. {
  156. return $this->subscriptionOrders;
  157. }
  158. public function addSubscriptionOrder(SubscriptionOrder $subscriptionOrder): self
  159. {
  160. if (!$this->subscriptionOrders->contains($subscriptionOrder)) {
  161. $this->subscriptionOrders[] = $subscriptionOrder;
  162. $subscriptionOrder->setParticipant($this);
  163. }
  164. return $this;
  165. }
  166. public function removeSubscriptionOrder(SubscriptionOrder $subscriptionOrder): self
  167. {
  168. if ($this->subscriptionOrders->contains($subscriptionOrder)) {
  169. $this->subscriptionOrders->removeElement($subscriptionOrder);
  170. // set the owning side to null (unless already changed)
  171. if ($subscriptionOrder->getParticipant() === $this) {
  172. $subscriptionOrder->setParticipant(null);
  173. }
  174. }
  175. return $this;
  176. }
  177. public function __toString()
  178. {
  179. return $this->getFirstName();
  180. }
  181. public function getForumUrl(): ?string
  182. {
  183. return $this->forumUrl;
  184. }
  185. public function setForumUrl(?string $forumUrl): self
  186. {
  187. $this->forumUrl = $forumUrl;
  188. return $this;
  189. }
  190. /**
  191. * @return Collection|SessionOrder[]
  192. */
  193. public function getSessionOrders(): Collection
  194. {
  195. return $this->sessionOrders;
  196. }
  197. public function addSessionOrder(SessionOrder $sessionOrder): self
  198. {
  199. if (!$this->sessionOrders->contains($sessionOrder)) {
  200. $this->sessionOrders[] = $sessionOrder;
  201. $sessionOrder->setParticipant($this);
  202. }
  203. return $this;
  204. }
  205. public function removeSessionOrder(SessionOrder $sessionOrder): self
  206. {
  207. if ($this->sessionOrders->contains($sessionOrder)) {
  208. $this->sessionOrders->removeElement($sessionOrder);
  209. // set the owning side to null (unless already changed)
  210. if ($sessionOrder->getParticipant() === $this) {
  211. $sessionOrder->setParticipant(null);
  212. }
  213. }
  214. return $this;
  215. }
  216. /**
  217. * @return Collection|VideoCoursesRegistration[]
  218. */
  219. public function getVideoCoursesRegistrations(): Collection
  220. {
  221. return $this->videoCoursesRegistrations;
  222. }
  223. public function addVideoCoursesRegistration(VideoCoursesRegistration $videoCoursesRegistration): self
  224. {
  225. if (!$this->videoCoursesRegistrations->contains($videoCoursesRegistration)) {
  226. $this->videoCoursesRegistrations[] = $videoCoursesRegistration;
  227. $videoCoursesRegistration->setParticipant($this);
  228. }
  229. return $this;
  230. }
  231. public function removeVideoCoursesRegistration(VideoCoursesRegistration $videoCoursesRegistration): self
  232. {
  233. if ($this->videoCoursesRegistrations->contains($videoCoursesRegistration)) {
  234. $this->videoCoursesRegistrations->removeElement($videoCoursesRegistration);
  235. // set the owning side to null (unless already changed)
  236. if ($videoCoursesRegistration->getParticipant() === $this) {
  237. $videoCoursesRegistration->setParticipant(null);
  238. }
  239. }
  240. return $this;
  241. }
  242. /**
  243. * @return Collection|TicketOrder[]
  244. */
  245. public function getTicketOrders(): Collection
  246. {
  247. return $this->ticketOrders;
  248. }
  249. public function addTicketOrder(TicketOrder $ticketOrder): self
  250. {
  251. if (!$this->ticketOrders->contains($ticketOrder)) {
  252. $this->ticketOrders[] = $ticketOrder;
  253. $ticketOrder->setParticipant($this);
  254. }
  255. return $this;
  256. }
  257. public function removeTicketOrder(TicketOrder $ticketOrder): self
  258. {
  259. if ($this->ticketOrders->contains($ticketOrder)) {
  260. $this->ticketOrders->removeElement($ticketOrder);
  261. // set the owning side to null (unless already changed)
  262. if ($ticketOrder->getParticipant() === $this) {
  263. $ticketOrder->setParticipant(null);
  264. }
  265. }
  266. return $this;
  267. }
  268. /**
  269. * @return Collection|UserPlacementTest[]
  270. */
  271. public function getUserPlacementTests(): Collection
  272. {
  273. return $this->userPlacementTests;
  274. }
  275. public function addUserPlacementTest(UserPlacementTest $userPlacementTest): self
  276. {
  277. if (!$this->userPlacementTests->contains($userPlacementTest)) {
  278. $this->userPlacementTests[] = $userPlacementTest;
  279. $userPlacementTest->setParticipant($this);
  280. }
  281. return $this;
  282. }
  283. public function removeUserPlacementTest(UserPlacementTest $userPlacementTest): self
  284. {
  285. if ($this->userPlacementTests->removeElement($userPlacementTest)) {
  286. // set the owning side to null (unless already changed)
  287. if ($userPlacementTest->getParticipant() === $this) {
  288. $userPlacementTest->setParticipant(null);
  289. }
  290. }
  291. return $this;
  292. }
  293. /**
  294. * @return Collection|Exam[]
  295. */
  296. public function getExams(): Collection
  297. {
  298. return $this->exams;
  299. }
  300. public function addExam(Exam $exam): self
  301. {
  302. if (!$this->exams->contains($exam)) {
  303. $this->exams[] = $exam;
  304. $exam->setStudent($this);
  305. }
  306. return $this;
  307. }
  308. public function removeExam(Exam $exam): self
  309. {
  310. if ($this->exams->removeElement($exam)) {
  311. // set the owning side to null (unless already changed)
  312. if ($exam->getStudent() === $this) {
  313. $exam->setStudent(null);
  314. }
  315. }
  316. return $this;
  317. }
  318. /**
  319. * @return Collection|TrainingReport[]
  320. */
  321. public function getTrainingReports(): Collection
  322. {
  323. return $this->trainingReports;
  324. }
  325. public function addTrainingReport(TrainingReport $trainingReport): self
  326. {
  327. if (!$this->trainingReports->contains($trainingReport)) {
  328. $this->trainingReports[] = $trainingReport;
  329. $trainingReport->setParticipant($this);
  330. }
  331. return $this;
  332. }
  333. public function removeTrainingReport(TrainingReport $trainingReport): self
  334. {
  335. if ($this->trainingReports->removeElement($trainingReport)) {
  336. // set the owning side to null (unless already changed)
  337. if ($trainingReport->getParticipant() === $this) {
  338. $trainingReport->setParticipant(null);
  339. }
  340. }
  341. return $this;
  342. }
  343. public function getIsChild(): ?bool
  344. {
  345. return $this->isChild;
  346. }
  347. public function setIsChild(?bool $isChild): self
  348. {
  349. $this->isChild = $isChild;
  350. return $this;
  351. }
  352. public function getIsTeen(): ?bool
  353. {
  354. return $this->isTeen;
  355. }
  356. public function setIsTeen(?bool $isTeen): self
  357. {
  358. $this->isTeen = $isTeen;
  359. return $this;
  360. }
  361. public function getIsAdult(): ?bool
  362. {
  363. return $this->isAdult;
  364. }
  365. public function setIsAdult(?bool $isAdult): self
  366. {
  367. $this->isAdult = $isAdult;
  368. return $this;
  369. }
  370. }