src/Entity/Hobit.php line 23

Open in your IDE?
  1. <?php
  2. /**
  3. * @Author: tristan
  4. * @Date: 2017-04-04 12:33:00
  5. * @Last Modified by: tristan
  6. * @Last Modified time: 2017-04-07 17:40:31
  7. */
  8. namespace App\Entity;
  9. use Cake\Chronos\Chronos;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\DBAL\Types\Types;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Symfony\Component\Validator\Constraints as Assert;
  15. /**
  16. * @ORM\Entity(repositoryClass="App\Repository\HobitRepository")
  17. * @ORM\Table(name="lf_hobit")
  18. * @ORM\HasLifecycleCallbacks()
  19. */
  20. class Hobit
  21. {
  22. const MY_HOME = "MY_HOME";
  23. const LEISURE = "LEISURE";
  24. const NOW = "NOW";
  25. const LAST = "LAST";
  26. const HISTORY = "HISTORY";
  27. /**
  28. * @ORM\Id
  29. * @ORM\Column(type="integer")
  30. * @ORM\GeneratedValue(strategy="AUTO")
  31. */
  32. protected $id;
  33. /**
  34. * @var datetime
  35. * @ORM\Column(name="dateCreatedByServer", type="datetime", nullable=true)
  36. */
  37. protected $dateCreated;
  38. /**
  39. * @var string
  40. * @ORM\Column(name="name", type="string", length=255, nullable=false)
  41. * @Assert\NotBlank(
  42. * message="positonGps.name_required",
  43. * payload={"code" = "name_required"},
  44. * groups={"new"}
  45. * )
  46. */
  47. protected $name;
  48. /**
  49. * @var string
  50. * @ORM\Column(name="group_name", type="string", length=255, nullable=true)
  51. */
  52. protected $groupName;
  53. /**
  54. * @var string
  55. * @ORM\Column(name="activity_type", type="string", nullable=true)
  56. */
  57. protected $activityType;
  58. /**
  59. */
  60. protected $groupNameTranslate;
  61. /**
  62. * @var boolean
  63. * @ORM\Column(name="group_verif", type="boolean", nullable=true)
  64. */
  65. protected $groupVerif;
  66. /**
  67. * @var string
  68. * @ORM\Column(name="address", type="string", length=255, nullable=false)
  69. * @Assert\NotBlank(
  70. * message="positonGps.address_required",
  71. * payload={"code" = "address_required"},
  72. * groups={"new"}
  73. * )
  74. */
  75. protected $address;
  76. /**
  77. * @var string
  78. * @ORM\Column(name="street", type="string", length=255, nullable=true)
  79. */
  80. protected $street;
  81. /**
  82. * @var string
  83. * @ORM\Column(name="number_street", type="string", length=255, nullable=true)
  84. */
  85. protected $numberStreet;
  86. /**
  87. * @var string
  88. * @ORM\Column(name="city", type="string", length=255, nullable=true)
  89. */
  90. protected $city;
  91. /**
  92. * @var string
  93. * @ORM\Column(name="postal_code", type="string", length=255, nullable=true)
  94. */
  95. protected $postalCode;
  96. /**
  97. * @var string
  98. * @ORM\Column(name="country", type="string", length=255, nullable=true)
  99. */
  100. protected $country;
  101. /**
  102. * @var string
  103. * @ORM\Column(name="latitude", type="string", length=255, nullable=false)
  104. * @Assert\NotBlank(
  105. * message="positonGps.latitude_required",
  106. * payload={"code" = "latitude_required"},
  107. * groups={"new"}
  108. * )
  109. */
  110. protected $latitude;
  111. /**
  112. * @var string
  113. * @ORM\Column(name="longitude", type="string", length=255, nullable=false)
  114. * @Assert\NotBlank(
  115. * message="positionGps.longitude_required",
  116. * payload={"code" = "longitude_required"},
  117. * groups={"new"}
  118. * )
  119. */
  120. protected $longitude;
  121. /**
  122. * @var string
  123. * @ORM\Column(name="type", type="string", length=255, nullable=false)
  124. * @Assert\NotBlank(
  125. * message="hobit.type_required",
  126. * payload={"code" = "type_required"},
  127. * groups={"new"}
  128. * )
  129. */
  130. protected $type;
  131. /**
  132. * @var string
  133. * @ORM\Column(name="location_type", type="string", length=255, nullable=false)
  134. * @Assert\NotBlank(
  135. * message="hobit.type_required",
  136. * payload={"code" = "type_required"},
  137. * groups={"new"}
  138. * )
  139. */
  140. protected $locationType;
  141. /**
  142. * @var string
  143. * @ORM\Column(name="id_place", type="text", nullable=true)
  144. * @Assert\NotBlank(
  145. * message="hobit.type_required",
  146. * payload={"code" = "type_required"},
  147. * groups={"new"}
  148. * )
  149. */
  150. protected $idPlace;
  151. /**
  152. * @var string
  153. * @ORM\Column(name="status", type="string", length=255, nullable=false)
  154. * @Assert\NotBlank(
  155. * message="hobit.status_required",
  156. * payload={"code" = "status_required"},
  157. * groups={"new"}
  158. * )
  159. */
  160. protected $status;
  161. /**
  162. * @var datetime
  163. * @ORM\Column(name="dateStartHobit", type="datetime", nullable=true)
  164. * @Assert\NotBlank(
  165. * message="hobit.dateStartHobit_required",
  166. * payload={"code" = "dateStartHobit_required"},
  167. * groups={"new"}
  168. * )
  169. */
  170. protected $dateStartHobit;
  171. /**
  172. * @var datetime
  173. * @ORM\Column(name="dateEndHobit", type="datetime", nullable=true)
  174. * @Assert\NotBlank(
  175. * message="hobit.dateEndHobit_required",
  176. * payload={"code" = "dateEndHobit_required"},
  177. * groups={"new"}
  178. * )
  179. */
  180. protected $dateEndHobit;
  181. /**
  182. * @var integer
  183. * @ORM\Column(name="numberRequest", type="integer", nullable=true)
  184. */
  185. protected $numberRequest;
  186. /**
  187. * @var integer
  188. * @ORM\ManyToOne(targetEntity="App\Entity\Hobit", inversedBy="childrens")
  189. * @ORM\JoinColumn(name="parent", referencedColumnName="id", nullable=true)
  190. */
  191. protected $parent;
  192. /**
  193. * @var hobits[]
  194. * @ORM\OneToMany(targetEntity="App\Entity\Hobit", mappedBy="parent")
  195. */
  196. protected $childrens;
  197. /**
  198. * @var hobitDates[]
  199. * @ORM\OneToMany(targetEntity="App\Entity\HobitDate", mappedBy="hobit")
  200. */
  201. protected $hobitDates;
  202. /**
  203. * @var user
  204. * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="positionsGps")
  205. */
  206. protected $user;
  207. /**
  208. * Constructor
  209. */
  210. public function __construct()
  211. {
  212. $this->childrens = new \Doctrine\Common\Collections\ArrayCollection();
  213. $this->hobitDates = new ArrayCollection();
  214. $this->dateCreated = Chronos::now("UTC");
  215. }
  216. /**
  217. * Get id
  218. *
  219. * @return integer
  220. */
  221. public function getId()
  222. {
  223. return $this->id;
  224. }
  225. /**
  226. * Set latitude
  227. *
  228. * @param string $latitude
  229. *
  230. * @return Hobit
  231. */
  232. public function setLatitude($latitude)
  233. {
  234. $this->latitude = $latitude;
  235. return $this;
  236. }
  237. /**
  238. * Get latitude
  239. *
  240. * @return string
  241. */
  242. public function getLatitude()
  243. {
  244. return $this->latitude;
  245. }
  246. /**
  247. * Set longitude
  248. *
  249. * @param string $longitude
  250. *
  251. * @return Hobit
  252. */
  253. public function setLongitude($longitude)
  254. {
  255. $this->longitude = $longitude;
  256. return $this;
  257. }
  258. /**
  259. * Get longitude
  260. *
  261. * @return string
  262. */
  263. public function getLongitude()
  264. {
  265. return $this->longitude;
  266. }
  267. /**
  268. * Set type
  269. *
  270. * @param string $type
  271. *
  272. * @return Hobit
  273. */
  274. public function setType($type)
  275. {
  276. $this->type = $type;
  277. return $this;
  278. }
  279. /**
  280. * Get type
  281. *
  282. * @return string
  283. */
  284. public function getType()
  285. {
  286. return $this->type;
  287. }
  288. /**
  289. * Set locationType
  290. *
  291. * @param string $locationType
  292. *
  293. * @return Hobit
  294. */
  295. public function setLocationType($locationType)
  296. {
  297. $this->locationType = $locationType;
  298. return $this;
  299. }
  300. /**
  301. * Get locationType
  302. *
  303. * @return string
  304. */
  305. public function getLocationType()
  306. {
  307. return $this->locationType;
  308. }
  309. /**
  310. * Set idPlace
  311. *
  312. * @param string $idPlace
  313. *
  314. * @return Hobit
  315. */
  316. public function setIdPlace($idPlace)
  317. {
  318. $this->idPlace = $idPlace;
  319. return $this;
  320. }
  321. /**
  322. * Get idPlace
  323. *
  324. * @return string
  325. */
  326. public function getIdPlace()
  327. {
  328. return $this->idPlace;
  329. }
  330. /**
  331. * Set name
  332. *
  333. * @param string $name
  334. *
  335. * @return Hobit
  336. */
  337. public function setName($name)
  338. {
  339. $this->name = $name;
  340. return $this;
  341. }
  342. /**
  343. * Get name
  344. *
  345. * @return string
  346. */
  347. public function getName()
  348. {
  349. return $this->name;
  350. }
  351. /**
  352. * Set groupVerif
  353. *
  354. * @param string $group
  355. *
  356. * @return Hobit
  357. */
  358. public function setGroupVerif($groupVerif)
  359. {
  360. $this->groupVerif = $groupVerif;
  361. return $this;
  362. }
  363. /**
  364. * Get groupVerif
  365. *
  366. * @return string
  367. */
  368. public function getGroupVerif()
  369. {
  370. return $this->groupVerif;
  371. }
  372. /**
  373. * Set address
  374. *
  375. * @param string $address
  376. *
  377. * @return Hobit
  378. */
  379. public function setAddress($address)
  380. {
  381. $this->address = $address;
  382. return $this;
  383. }
  384. /**
  385. * Get address
  386. *
  387. * @return string
  388. */
  389. public function getAddress()
  390. {
  391. return $this->address;
  392. }
  393. /**
  394. * Set dateStartHobit
  395. *
  396. * @param \DateTime $dateStartHobit
  397. *
  398. * @return Hobit
  399. */
  400. public function setDateStartHobit($dateStartHobit)
  401. {
  402. $this->dateStartHobit = $dateStartHobit;
  403. return $this;
  404. }
  405. /**
  406. * Get dateStartHobit
  407. *
  408. * @return \DateTime
  409. */
  410. public function getDateStartHobit()
  411. {
  412. return $this->dateStartHobit;
  413. }
  414. /**
  415. * Get dateStartHobitTranslate
  416. *
  417. * @return \String
  418. */
  419. public function getDateStartHobitTranslate()
  420. {
  421. $dateStartHobitTranslate = $this->dateStartHobit->format("d-m-Y H:i");
  422. return $dateStartHobitTranslate;
  423. }
  424. /**
  425. * Set dateEndHobit
  426. *
  427. * @param \DateTime $dateEndHobit
  428. *
  429. * @return Hobit
  430. */
  431. public function setDateEndHobit($dateEndHobit)
  432. {
  433. $this->dateEndHobit = $dateEndHobit;
  434. return $this;
  435. }
  436. /**
  437. * Get dateEndHobit
  438. *
  439. * @return \DateTime
  440. */
  441. public function getDateEndHobit()
  442. {
  443. return $this->dateEndHobit;
  444. }
  445. /**
  446. * Get dateEndHobitTranslate
  447. *
  448. * @return \String
  449. */
  450. public function getDateEndHobitTranslate()
  451. {
  452. $dateEndHobitTranslate = $this->dateEndHobit->format("d-m-Y H:i");
  453. return $dateEndHobitTranslate;
  454. }
  455. /**
  456. * Set numberRequest
  457. *
  458. * @param integer $numberRequest
  459. *
  460. * @return Hobit
  461. */
  462. public function setNumberRequest($numberRequest)
  463. {
  464. $this->numberRequest = $numberRequest;
  465. return $this;
  466. }
  467. /**
  468. * Get numberRequest
  469. *
  470. * @return integer
  471. */
  472. public function getNumberRequest()
  473. {
  474. return $this->numberRequest;
  475. }
  476. /**
  477. * Set status
  478. *
  479. * @param string $status
  480. *
  481. * @return Hobit
  482. */
  483. public function setStatus($status)
  484. {
  485. $this->status = $status;
  486. return $this;
  487. }
  488. /**
  489. * Get status
  490. *
  491. * @return string
  492. */
  493. public function getStatus()
  494. {
  495. return $this->status;
  496. }
  497. /**
  498. * Set parent.
  499. *
  500. * @param \HobitBundle\Entity\Hobit|null $parent
  501. *
  502. * @return Hobit
  503. */
  504. public function setParent(\HobitBundle\Entity\Hobit $parent = null)
  505. {
  506. $this->parent = $parent;
  507. return $this;
  508. }
  509. /**
  510. * Get parent.
  511. *
  512. * @return \HobitBundle\Entity\Hobit|null
  513. */
  514. public function getParent()
  515. {
  516. return $this->parent;
  517. }
  518. /**
  519. * Add children.
  520. *
  521. * @param \HobitBundle\Entity\Hobit $children
  522. *
  523. * @return Hobit
  524. */
  525. public function addChildren(\App\Entity\Hobit $children)
  526. {
  527. $this->childrens[] = $children;
  528. return $this;
  529. }
  530. /**
  531. * Remove children.
  532. *
  533. * @param \HobitBundle\Entity\Hobit $children
  534. *
  535. * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
  536. */
  537. public function removeChildren(\App\Entity\Hobit $children)
  538. {
  539. return $this->childrens->removeElement($children);
  540. }
  541. /**
  542. * Get childrens.
  543. *
  544. * @return \Doctrine\Common\Collections\Collection
  545. */
  546. public function getChildrens()
  547. {
  548. return $this->childrens;
  549. }
  550. /**
  551. * Add hobitDate.
  552. *
  553. * @param \HobitBundle\Entity\HobitDate $hobitDate
  554. *
  555. * @return Hobit
  556. */
  557. public function addHobitDate(\App\Entity\HobitDate $hobitDate)
  558. {
  559. $this->hobitDates[] = $hobitDate;
  560. return $this;
  561. }
  562. /**
  563. * Remove hobitDate.
  564. *
  565. * @param \HobitBundle\Entity\HobitDate $hobitDate
  566. *
  567. * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
  568. */
  569. public function removeHobitDate(\App\Entity\HobitDate $hobitDate)
  570. {
  571. return $this->hobitDates->removeElement($hobitDate);
  572. }
  573. /**
  574. * Get hobitDates.
  575. *
  576. * @return \Doctrine\Common\Collections\Collection
  577. */
  578. public function getHobitDates()
  579. {
  580. return $this->hobitDates;
  581. }
  582. /**
  583. * Set street.
  584. *
  585. * @param string|null $street
  586. *
  587. * @return Hobit
  588. */
  589. public function setStreet($street = null)
  590. {
  591. $this->street = $street;
  592. return $this;
  593. }
  594. /**
  595. * Get street.
  596. *
  597. * @return string|null
  598. */
  599. public function getStreet()
  600. {
  601. return $this->street;
  602. }
  603. /**
  604. * Set numberStreet.
  605. *
  606. * @param string|null $numberStreet
  607. *
  608. * @return Hobit
  609. */
  610. public function setNumberStreet($numberStreet = null)
  611. {
  612. $this->numberStreet = $numberStreet;
  613. return $this;
  614. }
  615. /**
  616. * Get numberStreet.
  617. *
  618. * @return string|null
  619. */
  620. public function getNumberStreet()
  621. {
  622. return $this->numberStreet;
  623. }
  624. /**
  625. * Set city.
  626. *
  627. * @param string|null $city
  628. *
  629. * @return Hobit
  630. */
  631. public function setCity($city = null)
  632. {
  633. $this->city = $city;
  634. return $this;
  635. }
  636. /**
  637. * Get city.
  638. *
  639. * @return string|null
  640. */
  641. public function getCity()
  642. {
  643. return $this->city;
  644. }
  645. /**
  646. * Set country.
  647. *
  648. * @param string|null $country
  649. *
  650. * @return Hobit
  651. */
  652. public function setCountry($country = null)
  653. {
  654. $this->country = $country;
  655. return $this;
  656. }
  657. /**
  658. * Get country.
  659. *
  660. * @return string|null
  661. */
  662. public function getCountry()
  663. {
  664. return $this->country;
  665. }
  666. /**
  667. * Set groupName.
  668. *
  669. * @param string|null $groupName
  670. *
  671. * @return Hobit
  672. */
  673. public function setGroupName($groupName = null)
  674. {
  675. $this->groupName = $groupName;
  676. return $this;
  677. }
  678. /**
  679. * Get groupName.
  680. *
  681. * @return string|null
  682. */
  683. public function getGroupName()
  684. {
  685. return $this->groupName;
  686. }
  687. /**
  688. * Get groupNameTranslate.
  689. *
  690. * @return string|null
  691. */
  692. public function getGroupNameTranslate()
  693. {
  694. $groupNameTranslate = $this->groupName;
  695. if($this->groupName == "home"){
  696. $groupNameTranslate = "chez vous";
  697. }
  698. else if($this->groupName == "work"){
  699. $groupNameTranslate = "travail";
  700. }
  701. return $groupNameTranslate;
  702. }
  703. /**
  704. * Set postalCode.
  705. *
  706. * @param string|null $postalCode
  707. *
  708. * @return Hobit
  709. */
  710. public function setPostalCode($postalCode = null)
  711. {
  712. $this->postalCode = $postalCode;
  713. return $this;
  714. }
  715. /**
  716. * Get postalCode.
  717. *
  718. * @return string|null
  719. */
  720. public function getPostalCode()
  721. {
  722. return $this->postalCode;
  723. }
  724. public function isGroupVerif(): ?bool
  725. {
  726. return $this->groupVerif;
  727. }
  728. public function getUser(): ?User
  729. {
  730. return $this->user;
  731. }
  732. public function setUser(?User $user): self
  733. {
  734. $this->user = $user;
  735. return $this;
  736. }
  737. public function getDateCreated(): ?\DateTimeInterface
  738. {
  739. return $this->dateCreated;
  740. }
  741. public function setDateCreated(?\DateTimeInterface $dateCreated): self
  742. {
  743. $this->dateCreated = $dateCreated;
  744. return $this;
  745. }
  746. public function getActivityType(): ?string
  747. {
  748. return $this->activityType;
  749. }
  750. public function setActivityType(?string $activityType): self
  751. {
  752. $this->activityType = $activityType;
  753. return $this;
  754. }
  755. }