src/Entity/User.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 Symfony\Component\Validator\Constraints as Assert;
  7. /**
  8. * User
  9. *
  10. * @ORM\Table(name="user", uniqueConstraints={@ORM\UniqueConstraint(name="user_id_uindex", columns={"id"})}, indexes={@ORM\Index(name="user_user_id_fk", columns={"godfather_id"}), @ORM\Index(name="user_manager_id_fk", columns={"manager_id"})})
  11. * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
  12. */
  13. class User
  14. {
  15. /**
  16. * @var int
  17. *
  18. * @ORM\Column(name="id", type="integer", nullable=false)
  19. * @ORM\Id
  20. * @ORM\GeneratedValue(strategy="IDENTITY")
  21. */
  22. private $id;
  23. /**
  24. * @var string|null
  25. *
  26. * @ORM\Column(name="last_name", type="string", length=255, nullable=true)
  27. */
  28. private $lastName;
  29. /**
  30. * @var string|null
  31. *
  32. * @ORM\Column(name="first_name", type="string", length=255, nullable=true)
  33. */
  34. private $firstName;
  35. /**
  36. * @var string|null
  37. *
  38. * @ORM\Column(name="position", type="string", length=255, nullable=true)
  39. */
  40. private $position;
  41. /**
  42. * @var bool|null
  43. *
  44. * @ORM\Column(name="pro", type="boolean", nullable=true)
  45. */
  46. private $pro = false;
  47. /**
  48. * @var string|null
  49. *
  50. * @ORM\Column(name="godfather_code", type="string", length=255, nullable=true)
  51. */
  52. private $godfatherCode;
  53. /**
  54. * @var \DateTime|null
  55. *
  56. * @ORM\Column(name="creation_date", type="datetime", nullable=true)
  57. */
  58. private $creationDate;
  59. /**
  60. * @var string|null
  61. *
  62. * @ORM\Column(name="address", type="string", length=255, nullable=true)
  63. */
  64. private $address;
  65. /**
  66. * @var string|null
  67. *
  68. * @ORM\Column(name="address_2", type="string", length=255, nullable=true)
  69. */
  70. private $address2;
  71. /**
  72. * @var string|null
  73. *
  74. * @ORM\Column(name="zip_code", type="string", length=32, nullable=true)
  75. */
  76. private $zipCode;
  77. /**
  78. * @var string|null
  79. *
  80. * @ORM\Column(name="city", type="string", length=255, nullable=true)
  81. */
  82. private $city;
  83. /**
  84. * @var string|null
  85. *
  86. * @ORM\Column(name="phone", type="string", length=255, nullable=true)
  87. */
  88. private $phone;
  89. /**
  90. * @var string|null
  91. *
  92. * @ORM\Column(name="email", type="string", length=255, nullable=true)
  93. */
  94. private $email;
  95. /**
  96. * @var bool|null
  97. *
  98. * @ORM\Column(name="owner", type="boolean", nullable=true)
  99. */
  100. private $owner = false;
  101. /**
  102. * @var \DateTime|null
  103. *
  104. * @ORM\Column(name="date_of_birth", type="datetime", nullable=true)
  105. */
  106. private $dateOfBirth;
  107. /**
  108. * @var string|null
  109. *
  110. * @ORM\Column(name="pdl_number", type="string", length=255, nullable=true)
  111. */
  112. private $pdlNumber;
  113. /**
  114. * @var string|null
  115. *
  116. * @ORM\Column(name="pce_number", type="string", length=255, nullable=true)
  117. */
  118. private $pceNumber;
  119. /**
  120. * @var bool|null
  121. *
  122. * @ORM\Column(name="gas", type="boolean", nullable=true)
  123. */
  124. private $gas = false;
  125. /**
  126. * @var bool|null
  127. *
  128. * @ORM\Column(name="electricity", type="boolean", nullable=true)
  129. */
  130. private $electricity = false;
  131. /**
  132. * @var bool|null
  133. *
  134. * @ORM\Column(name="photovoltaique", type="boolean", nullable=true)
  135. */
  136. private $photovoltaique = false;
  137. /**
  138. * @var bool|null
  139. *
  140. * @ORM\Column(name="thermostat", type="boolean", nullable=true)
  141. */
  142. private $thermostat = false;
  143. /**
  144. * @var Manager
  145. *
  146. * @ORM\ManyToOne(targetEntity="Manager")
  147. * @ORM\JoinColumns({
  148. * @ORM\JoinColumn(name="manager_id", referencedColumnName="id")
  149. * })
  150. */
  151. private $manager;
  152. /**
  153. * @var User
  154. *
  155. * @ORM\ManyToOne(targetEntity="User")
  156. * @ORM\JoinColumns({
  157. * @ORM\JoinColumn(name="godfather_id", referencedColumnName="id")
  158. * })
  159. */
  160. private $godfather;
  161. /**
  162. * @ORM\OneToMany(targetEntity="Company", mappedBy="user")
  163. */
  164. private $companies;
  165. /**
  166. * @var Account
  167. *
  168. * @ORM\OneToOne(targetEntity="Account", mappedBy="user")
  169. */
  170. private $account;
  171. /**
  172. * @var string|null
  173. *
  174. * @ORM\Column(name="fe_invitation_token", type="string", length=255, nullable=true)
  175. */
  176. private $feInvitationToken;
  177. /**
  178. * @var \DateTime|null
  179. *
  180. * @ORM\Column(name="fe_invitation_date", type="datetime", nullable=true)
  181. */
  182. private $feInvitationDate;
  183. /**
  184. * @var Device
  185. *
  186. * @ORM\OneToOne(targetEntity="Device", mappedBy="user")
  187. */
  188. private $device;
  189. /**
  190. * @var bool|null
  191. *
  192. * @ORM\Column(name="archived", type="boolean", nullable=true)
  193. */
  194. private $archived = false;
  195. /**
  196. * @var Collection
  197. *
  198. * @ORM\OneToMany(targetEntity="Contract", mappedBy="user")
  199. */
  200. private $contracts;
  201. /**
  202. * @var string|null
  203. *
  204. * @ORM\Column(name="referral_code", type="string", length=10, nullable=true)
  205. */
  206. private $referralCode;
  207. /**
  208. * @var string|null
  209. *
  210. * @ORM\Column(name="step_in_process", type="string", length=100, nullable=true)
  211. */
  212. private $stepInProcess;
  213. /**
  214. * @var string|null
  215. *
  216. * @ORM\Column(name="comment", type="string", length=65535, nullable=true)
  217. */
  218. private $comment;
  219. public function __construct()
  220. {
  221. $this->companies = new ArrayCollection();
  222. }
  223. /**
  224. * @return int
  225. */
  226. public function getId()
  227. {
  228. return $this->id;
  229. }
  230. /**
  231. * @param int $id
  232. */
  233. public function setId($id)
  234. {
  235. $this->id = $id;
  236. }
  237. /**
  238. * @return string|null
  239. */
  240. public function getLastName()
  241. {
  242. return $this->lastName;
  243. }
  244. /**
  245. * @param string|null $lastName
  246. */
  247. public function setLastName($lastName)
  248. {
  249. $this->lastName = $lastName;
  250. }
  251. /**
  252. * @return string|null
  253. */
  254. public function getFirstName()
  255. {
  256. return $this->firstName;
  257. }
  258. /**
  259. * @param string|null $firstName
  260. */
  261. public function setFirstName($firstName)
  262. {
  263. $this->firstName = $firstName;
  264. }
  265. /**
  266. * @return string|null
  267. */
  268. public function getPosition(): ?string
  269. {
  270. return $this->position;
  271. }
  272. /**
  273. * @param string|null $position
  274. */
  275. public function setPosition(?string $position): void
  276. {
  277. $this->position = $position;
  278. }
  279. /**
  280. * @return bool|null
  281. */
  282. public function getPro()
  283. {
  284. return $this->pro;
  285. }
  286. /**
  287. * @param bool|null $pro
  288. */
  289. public function setPro($pro)
  290. {
  291. $this->pro = $pro;
  292. }
  293. /**
  294. * @return string|null
  295. */
  296. public function getGodfatherCode()
  297. {
  298. return $this->godfatherCode;
  299. }
  300. /**
  301. * @param string|null $godfatherCode
  302. */
  303. public function setGodfatherCode($godfatherCode)
  304. {
  305. $this->godfatherCode = $godfatherCode;
  306. }
  307. /**
  308. * @return \DateTime|null
  309. */
  310. public function getCreationDate()
  311. {
  312. return $this->creationDate;
  313. }
  314. /**
  315. * @param \DateTime|null $creationDate
  316. */
  317. public function setCreationDate($creationDate)
  318. {
  319. $this->creationDate = $creationDate;
  320. }
  321. /**
  322. * @return string|null
  323. */
  324. public function getAddress()
  325. {
  326. return $this->address;
  327. }
  328. /**
  329. * @param string|null $address
  330. */
  331. public function setAddress($address)
  332. {
  333. $this->address = $address;
  334. }
  335. /**
  336. * @return string|null
  337. */
  338. public function getAddress2()
  339. {
  340. return $this->address2;
  341. }
  342. /**
  343. * @param string|null $address2
  344. */
  345. public function setAddress2($address2)
  346. {
  347. $this->address2 = $address2;
  348. }
  349. /**
  350. * @return string|null
  351. */
  352. public function getZipCode()
  353. {
  354. return $this->zipCode;
  355. }
  356. /**
  357. * @param string|null $zipCode
  358. */
  359. public function setZipCode($zipCode)
  360. {
  361. $this->zipCode = $zipCode;
  362. }
  363. /**
  364. * @return string|null
  365. */
  366. public function getCity()
  367. {
  368. return $this->city;
  369. }
  370. /**
  371. * @param string|null $city
  372. */
  373. public function setCity($city)
  374. {
  375. $this->city = $city;
  376. }
  377. /**
  378. * @return string|null
  379. */
  380. public function getPhone()
  381. {
  382. return $this->phone;
  383. }
  384. /**
  385. * @param string|null $phone
  386. */
  387. public function setPhone($phone)
  388. {
  389. $this->phone = $phone;
  390. }
  391. /**
  392. * @return string|null
  393. */
  394. public function getEmail()
  395. {
  396. return $this->email;
  397. }
  398. /**
  399. * @param string|null $email
  400. */
  401. public function setEmail($email)
  402. {
  403. $this->email = $email;
  404. }
  405. /**
  406. * @return bool|null
  407. */
  408. public function getOwner()
  409. {
  410. return $this->owner;
  411. }
  412. /**
  413. * @param bool|null $owner
  414. */
  415. public function setOwner($owner)
  416. {
  417. $this->owner = $owner;
  418. }
  419. /**
  420. * @return \DateTime|null
  421. */
  422. public function getDateOfBirth(): ?\DateTime
  423. {
  424. return $this->dateOfBirth;
  425. }
  426. /**
  427. * @param \DateTime|null $dateOfBirth
  428. */
  429. public function setDateOfBirth(?\DateTime $dateOfBirth): void
  430. {
  431. $this->dateOfBirth = $dateOfBirth;
  432. }
  433. /**
  434. * @return string|null
  435. */
  436. public function getPdlNumber()
  437. {
  438. return $this->pdlNumber;
  439. }
  440. /**
  441. * @param string|null $pdlNumber
  442. */
  443. public function setPdlNumber($pdlNumber)
  444. {
  445. $this->pdlNumber = $pdlNumber;
  446. }
  447. /**
  448. * @return string|null
  449. */
  450. public function getPceNumber()
  451. {
  452. return $this->pceNumber;
  453. }
  454. /**
  455. * @param string|null $pceNumber
  456. */
  457. public function setPceNumber($pceNumber)
  458. {
  459. $this->pceNumber = $pceNumber;
  460. }
  461. /**
  462. * @return bool|null
  463. */
  464. public function getGas()
  465. {
  466. return $this->gas;
  467. }
  468. /**
  469. * @param bool|null $gas
  470. */
  471. public function setGas($gas)
  472. {
  473. $this->gas = $gas;
  474. }
  475. /**
  476. * @return bool|null
  477. */
  478. public function getElectricity()
  479. {
  480. return $this->electricity;
  481. }
  482. /**
  483. * @param bool|null $electricity
  484. */
  485. public function setElectricity($electricity)
  486. {
  487. $this->electricity = $electricity;
  488. }
  489. public function getPhotovoltaique(): ?bool
  490. {
  491. return $this->photovoltaique;
  492. }
  493. public function setPhotovoltaique(?bool $photovoltaique): void
  494. {
  495. $this->photovoltaique = $photovoltaique;
  496. }
  497. public function getThermostat(): ?bool
  498. {
  499. return $this->thermostat;
  500. }
  501. public function setThermostat(?bool $thermostat): void
  502. {
  503. $this->thermostat = $thermostat;
  504. }
  505. /**
  506. * @return Manager
  507. */
  508. public function getManager()
  509. {
  510. return $this->manager;
  511. }
  512. /**
  513. * @param Manager $manager
  514. */
  515. public function setManager($manager)
  516. {
  517. $this->manager = $manager;
  518. }
  519. /**
  520. * @return User
  521. */
  522. public function getGodfather()
  523. {
  524. return $this->godfather;
  525. }
  526. /**
  527. * @param User $godfather
  528. */
  529. public function setGodfather($godfather)
  530. {
  531. $this->godfather = $godfather;
  532. }
  533. /**
  534. * @return ArrayCollection
  535. */
  536. public function getCompanies()
  537. {
  538. return $this->companies;
  539. }
  540. /**
  541. * @param ArrayCollection $companies
  542. */
  543. public function setCompanies($companies)
  544. {
  545. $this->companies = $companies;
  546. }
  547. public function addCompany(Company $company)
  548. {
  549. if (!$this->companies->contains($company)) {
  550. $this->companies[] = $company;
  551. $company->setUser($this);
  552. }
  553. return $this;
  554. }
  555. public function removeCompany(Company $company)
  556. {
  557. if ($this->companies->removeElement($company)) {
  558. // set the owning side to null (unless already changed)
  559. if ($company->getUser() === $this) {
  560. $company->setUser(null);
  561. }
  562. }
  563. return $this;
  564. }
  565. /**
  566. * @return Account|null
  567. */
  568. public function getAccount(): ?Account
  569. {
  570. return $this->account;
  571. }
  572. /**
  573. * @return string|null
  574. */
  575. public function getFeInvitationToken(): ?string
  576. {
  577. return $this->feInvitationToken;
  578. }
  579. /**
  580. * @param string|null $feInvitationToken
  581. */
  582. public function setFeInvitationToken(?string $feInvitationToken): void
  583. {
  584. $this->feInvitationToken = $feInvitationToken;
  585. }
  586. /**
  587. * @return \DateTime|null
  588. */
  589. public function getFeInvitationDate(): ?\DateTime
  590. {
  591. return $this->feInvitationDate;
  592. }
  593. /**
  594. * @param \DateTime|null $feInvitationDate
  595. */
  596. public function setFeInvitationDate(?\DateTime $feInvitationDate): void
  597. {
  598. $this->feInvitationDate = $feInvitationDate;
  599. }
  600. /**
  601. * @return Device
  602. */
  603. public function getDevice(): Device
  604. {
  605. return $this->device;
  606. }
  607. /**
  608. * @param Device $device
  609. */
  610. public function setDevice(Device $device): void
  611. {
  612. $this->device = $device;
  613. }
  614. /**
  615. * @return bool|null
  616. */
  617. public function getArchived(): ?bool
  618. {
  619. return $this->archived;
  620. }
  621. /**
  622. * @param bool|null $archived
  623. */
  624. public function setArchived(?bool $archived): void
  625. {
  626. $this->archived = $archived;
  627. }
  628. /**
  629. * @return Collection
  630. */
  631. public function getContracts(): Collection
  632. {
  633. return $this->contracts;
  634. }
  635. public function getReferralCode(): ?string
  636. {
  637. return $this->referralCode;
  638. }
  639. public function setReferralCode(?string $referralCode): void
  640. {
  641. $this->referralCode = $referralCode;
  642. }
  643. /**
  644. * @param Collection $contracts
  645. */
  646. public function setContracts(Collection $contracts): void
  647. {
  648. $this->contracts = $contracts;
  649. }
  650. public function getStepInProcess(): ?string
  651. {
  652. return $this->stepInProcess;
  653. }
  654. public function setStepInProcess(?string $stepInProcess): void
  655. {
  656. $this->stepInProcess = $stepInProcess;
  657. }
  658. public function getComment(): ?string
  659. {
  660. return $this->comment;
  661. }
  662. public function setComment(?string $comment): void
  663. {
  664. $this->comment = $comment;
  665. }
  666. public function getServicesString()
  667. {
  668. $services = [];
  669. foreach ($this->getContracts() as $contract) {
  670. foreach ($contract->getTypes() as $type) {
  671. if (!in_array($type, $services)) {
  672. $services[] = $type;
  673. }
  674. }
  675. }
  676. return implode(", ", $services);
  677. }
  678. }