src/Entity/Child.php line 95

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use ApiPlatform\Core\Annotation\ApiFilter;
  5. use ApiPlatform\Core\Annotation\ApiResource;
  6. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. /**
  13. * @ORM\Entity
  14. * @ApiResource(
  15. * iri="http://schema.org/Thing",
  16. * collectionOperations={
  17. * "get"={
  18. * "access_control"="is_granted('ROLE_USER')",
  19. * "method"="GET",
  20. * "normalization_context"={
  21. * "groups"={"output"}
  22. * },
  23. * "denormalization_context"={
  24. * "groups"={"input"}
  25. * }
  26. * },
  27. * "post"={
  28. * "access_control"="is_granted('ROLE_USER')",
  29. * "method"="POST",
  30. * "normalization_context"={
  31. * "groups"={"output"}
  32. * },
  33. * "denormalization_context"={
  34. * "groups"={"input"}
  35. * }
  36. * }
  37. * },
  38. * itemOperations={
  39. * "delete"={
  40. * "access_control"="is_granted('IS_OWNER', object) or is_granted('ROLE_ADMIN') or is_granted('ROLE_SUPER_ADMIN')",
  41. * "normalization_context"={
  42. * "groups"={"output"}
  43. * },
  44. * "denormalization_context"={
  45. * "groups"={"input"}
  46. * }
  47. * },
  48. * "get"={
  49. * "access_control"="is_granted('IS_OWNER', object) or is_granted('ROLE_ADMIN') or is_granted('ROLE_SUPER_ADMIN')",
  50. * "method"="GET",
  51. * "normalization_context"={
  52. * "groups"={"output"}
  53. * },
  54. * "denormalization_context"={
  55. * "groups"={"input"}
  56. * }
  57. * },
  58. * "put"={
  59. * "access_control"="is_granted('IS_OWNER', object) or is_granted('ROLE_ADMIN') or is_granted('ROLE_SUPER_ADMIN')",
  60. * "method"="PUT",
  61. * "normalization_context"={
  62. * "groups"={"output"}
  63. * },
  64. * "denormalization_context"={
  65. * "groups"={"input"}
  66. * }
  67. * }
  68. * },
  69. * attributes={
  70. * "filters"={
  71. * "child.search_filter",
  72. * "child.order_filter",
  73. * "child.date_filter",
  74. * },
  75. * "normalization_context"={
  76. * "groups"={""}
  77. * },
  78. * "denormalization_context"={
  79. * "groups"={""}
  80. * },
  81. * "pagination_items_per_page"=10,
  82. * "pagination_client_items_per_page"=true
  83. * }
  84. * )
  85. *
  86. * The most generic type of item.
  87. *
  88. * @see http://schema.org/Thing Documentation on Schema.org
  89. */
  90. class Child extends AbstractTimestamp
  91. {
  92. /**
  93. * @ORM\Id
  94. * @ORM\GeneratedValue(strategy="AUTO")
  95. * @ORM\Column(type="integer")
  96. * @Groups({"output"})
  97. *
  98. * @var int|null
  99. */
  100. protected $id;
  101. /**
  102. * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="children")
  103. *
  104. * @var User|null
  105. */
  106. protected $createdBy;
  107. /**
  108. * @ORM\Column(type="datetime")
  109. * @Groups({"output", "input"})
  110. *
  111. * @var \DateTimeInterface|null
  112. *
  113. */
  114. protected $birthdate;
  115. /**
  116. * @ORM\Column(type="string", length=180, nullable=false)
  117. * @Groups({"output", "input"})
  118. *
  119. * #[ApiFilter(SearchFilter::class, strategy: 'partial')]
  120. *
  121. * @var string|null
  122. */
  123. protected $firstName;
  124. /**
  125. * @ORM\Column(type="string", length=180, nullable=true)
  126. * @Groups({"output", "input"})
  127. *
  128. * @var string|null
  129. */
  130. protected $middleName;
  131. /**
  132. * @ORM\Column(type="string", length=180, nullable=false)
  133. * @Groups({"output", "input"})
  134. *
  135. * @var string|null
  136. */
  137. protected $lastName;
  138. /**
  139. * @ORM\ManyToOne(targetEntity="App\Entity\Lookup")
  140. * @Groups({"output", "input"})
  141. *
  142. * @var Lookup|null
  143. */
  144. protected $stateOfResidence;
  145. /**
  146. * @ORM\ManyToOne(targetEntity="App\Entity\Lookup")
  147. * @Groups({"output", "input"})
  148. *
  149. * @var Lookup|null
  150. */
  151. protected $suffix;
  152. /**
  153. * @ORM\OneToMany(targetEntity="App\Entity\Referral", mappedBy="child")
  154. * @ORM\JoinColumn(referencedColumnName="id")
  155. *
  156. * @var Collection<Referral>
  157. *
  158. * @Assert\NotNull
  159. */
  160. protected $referrals;
  161. public function __construct()
  162. {
  163. $this->referrals = new ArrayCollection();
  164. }
  165. public function getId(): ?int
  166. {
  167. return $this->id;
  168. }
  169. public function setBirthdate(?\DateTimeInterface $birthdate): self
  170. {
  171. $this->birthdate = $birthdate;
  172. return $this;
  173. }
  174. public function getBirthdate(): ?\DateTimeInterface
  175. {
  176. return $this->birthdate;
  177. }
  178. public function setFirstName(?string $firstName): self
  179. {
  180. $this->firstName = $firstName;
  181. return $this;
  182. }
  183. public function getFirstName(): ?string
  184. {
  185. return $this->firstName;
  186. }
  187. public function setMiddleName(?string $middleName): self
  188. {
  189. $this->middleName = $middleName;
  190. return $this;
  191. }
  192. public function getMiddleName(): ?string
  193. {
  194. return $this->middleName;
  195. }
  196. public function setLastName(?string $lastName): self
  197. {
  198. $this->lastName = $lastName;
  199. return $this;
  200. }
  201. public function getLastName(): ?string
  202. {
  203. return $this->lastName;
  204. }
  205. public function setStateOfResidence(?Lookup $stateOfResidence): self
  206. {
  207. $this->stateOfResidence = $stateOfResidence;
  208. return $this;
  209. }
  210. public function getStateOfResidence(): ?Lookup
  211. {
  212. return $this->stateOfResidence;
  213. }
  214. public function setSuffix(?Lookup $suffix): self
  215. {
  216. $this->suffix = $suffix;
  217. return $this;
  218. }
  219. public function getSuffix(): ?Lookup
  220. {
  221. return $this->suffix;
  222. }
  223. public function addReferral(Referral $referral): self
  224. {
  225. $this->referrals[] = $referral;
  226. return $this;
  227. }
  228. public function removeReferral(Referral $referral): self
  229. {
  230. $this->referrals->removeElement($referral);
  231. return $this;
  232. }
  233. public function getReferrals(): Collection
  234. {
  235. return $this->referrals;
  236. }
  237. }