src/Entity/CustomerProfile.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Serializer\Annotation\Groups;
  5. /**
  6. * CustomerProfile
  7. *
  8. * @ORM\Table(name="customer_profile")
  9. * @ORM\Entity
  10. */
  11. class CustomerProfile
  12. {
  13. /**
  14. * @var int
  15. *
  16. * @ORM\Column(name="id", type="integer", nullable=false)
  17. * @ORM\Id
  18. * @ORM\GeneratedValue(strategy="IDENTITY")
  19. * @Groups({"agenda-api"})
  20. */
  21. private $id;
  22. /**
  23. * @var string|null
  24. *
  25. * @ORM\Column(name="last_name", type="string", length=255, nullable=true, options={"default"="NULL"})
  26. * @Groups({"agenda-api"})
  27. */
  28. private $lastName;
  29. /**
  30. * @var string|null
  31. *
  32. * @ORM\Column(name="first_name", type="string", length=255, nullable=true, options={"default"="NULL"})
  33. * @Groups({"agenda-api"})
  34. */
  35. private $firstName;
  36. /**
  37. * @var string|null
  38. *
  39. * @ORM\Column(name="family_relationship", type="string", length=255, nullable=true, options={"default"="NULL"})
  40. * @Groups({"agenda-api"})
  41. */
  42. private $familyRelationship;
  43. /**
  44. * @var \Doctrine\Common\Collections\Collection
  45. *
  46. * @ORM\ManyToMany(targetEntity="User", mappedBy="customerProfile")
  47. */
  48. private $user = array();
  49. /**
  50. * Constructor
  51. */
  52. public function __construct()
  53. {
  54. $this->user = new \Doctrine\Common\Collections\ArrayCollection();
  55. }
  56. /**
  57. * @return int
  58. */
  59. public function getId(): int
  60. {
  61. return $this->id;
  62. }
  63. /**
  64. * @param int $id
  65. */
  66. public function setId(int $id): void
  67. {
  68. $this->id = $id;
  69. }
  70. /**
  71. * @return string|null
  72. */
  73. public function getLastName(): ?string
  74. {
  75. return $this->lastName;
  76. }
  77. /**
  78. * @param string|null $lastName
  79. */
  80. public function setLastName(?string $lastName): void
  81. {
  82. $this->lastName = $lastName;
  83. }
  84. /**
  85. * @return string|null
  86. */
  87. public function getFirstName(): ?string
  88. {
  89. return $this->firstName;
  90. }
  91. /**
  92. * @param string|null $firstName
  93. */
  94. public function setFirstName(?string $firstName): void
  95. {
  96. $this->firstName = $firstName;
  97. }
  98. /**
  99. * @return string|null
  100. */
  101. public function getFamilyRelationship(): ?string
  102. {
  103. return $this->familyRelationship;
  104. }
  105. /**
  106. * @param string|null $familyRelationship
  107. */
  108. public function setFamilyRelationship(?string $familyRelationship): void
  109. {
  110. $this->familyRelationship = $familyRelationship;
  111. }
  112. /**
  113. * @return \Doctrine\Common\Collections\Collection
  114. */
  115. public function getUser()
  116. {
  117. return $this->user;
  118. }
  119. /**
  120. * @param \Doctrine\Common\Collections\Collection $user
  121. */
  122. public function setUser($user): void
  123. {
  124. $this->user = $user;
  125. }
  126. public function isFirstReservation(Partner $partner, $em): bool
  127. {
  128. $count = $em->getRepository(Reservation::class)->countReservation($partner, null, $this);
  129. if ($count && $count > 0) {
  130. return false;
  131. }
  132. return true;
  133. }
  134. public function isOwnedBy(User $user): bool
  135. {
  136. foreach ($this->getUser() as $userIn)
  137. {
  138. if ($userIn->getId() == $user->getId()) {
  139. return true;
  140. }
  141. }
  142. return false;
  143. }
  144. }