src/Entity/Profile.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\SuperClass\BaseEntity;
  4. use App\Repository\ProfileRepository;
  5. use App\Validator\IsValidOwner;
  6. use DateTime;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. /**
  10. * @ORM\Entity(repositoryClass=ProfileRepository::class)
  11. */
  12. class Profile extends BaseEntity
  13. {
  14. /**
  15. * @Assert\NotBlank()
  16. * @ORM\Column(type="string", length=255)
  17. */
  18. private $f_name;
  19. /**
  20. * @ORM\Column(type="string", length=255)
  21. * @Assert\NotBlank()
  22. */
  23. private $l_name;
  24. /**
  25. * @ORM\Column(type="date", nullable=true )
  26. * @Assert\NotBlank()
  27. */
  28. private ?DateTime $dob = null;
  29. /**
  30. * @ORM\Column(type="string", nullable=true)
  31. * @Assert\NotBlank()
  32. */
  33. private $gender;
  34. /**
  35. * @Assert\NotBlank()
  36. * @ORM\Column(type="string", length=255)
  37. */
  38. private $phone;
  39. /**
  40. * @ORM\OneToOne(targetEntity=User::class, inversedBy="profile", cascade={"persist", "remove"})
  41. * @IsValidOwner()
  42. */
  43. protected ?User $owner;
  44. /**
  45. * @ORM\ManyToOne(targetEntity=User::class, inversedBy="profiles")
  46. */
  47. private $created_by;
  48. public function getFName(): ?string
  49. {
  50. return $this->f_name;
  51. }
  52. public function setFName(string $f_name): self
  53. {
  54. $this->f_name = $f_name;
  55. return $this;
  56. }
  57. public function getLName(): ?string
  58. {
  59. return $this->l_name;
  60. }
  61. public function setLName(string $l_name): self
  62. {
  63. $this->l_name = $l_name;
  64. return $this;
  65. }
  66. public function getDob(): ?string
  67. {
  68. if (!is_null($this->dob)) {
  69. return $this->dob->format('Y-m-d');
  70. }
  71. return '';
  72. }
  73. /**
  74. * @throws \Exception
  75. */
  76. public function setDob($dob): self
  77. {
  78. $this->dob = new DateTime($dob);
  79. return $this;
  80. }
  81. public function getGender(): ?string
  82. {
  83. return $this->gender;
  84. }
  85. public function setGender(string $gender): self
  86. {
  87. $this->gender = $gender;
  88. return $this;
  89. }
  90. public function getPhone(): ?string
  91. {
  92. return $this->phone;
  93. }
  94. public function setPhone(string $phone): self
  95. {
  96. $this->phone = $phone;
  97. return $this;
  98. }
  99. public function getOwner(): ?User
  100. {
  101. return $this->owner;
  102. }
  103. public function setOwner(?User $created_by): self
  104. {
  105. $this->owner = $created_by;
  106. return $this;
  107. }
  108. public function getCreatedBy(): ?User
  109. {
  110. return $this->created_by;
  111. }
  112. public function setCreatedBy(?User $created_by): self
  113. {
  114. $this->created_by = $created_by;
  115. return $this;
  116. }
  117. }