src/Entity/User.php line 16
<?phpnamespace App\Entity;use App\Repository\UserRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;use Symfony\Component\Security\Core\User\UserInterface;#[ORM\Entity(repositoryClass: UserRepository::class)]#[ORM\Table(name: '`user`')]#[UniqueEntity(fields: ['email'], message: 'An account with this email already exists. Please log in instead.')]class User implements UserInterface, PasswordAuthenticatedUserInterface{const ROLE_USER = 'ROLE_USER';const ROLE_ADMIN = 'ROLE_ADMIN';const VALIDITY_IN_DAYS = 730;const REJECT_REASON_INVALID_IDENTITY = 'II';const REJECT_REASON_MEMBERSHIP_FEE_NOT_RECEIVED = 'MN';#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 180, unique: true)]private ?string $email = null;#[ORM\Column]private array $roles = [];/*** @var string The hashed password*/#[ORM\Column]private ?string $password = null;#[ORM\Column(length: 255)]private ?string $firstName = null;#[ORM\Column(length: 255, nullable: true)]private ?string $lastName = null;#[ORM\Column(length: 255, nullable: true)]private ?string $address = null;#[ORM\Column(length: 255, nullable: true)]private ?string $phoneNo = null;#[ORM\OneToMany(mappedBy: 'user', targetEntity: UserImage::class, orphanRemoval: true)]#@ORM\JoinColumn(name="id", referencedColumnName="user_id")private Collection $userImages;#[ORM\ManyToOne(inversedBy: 'users', fetch:"EAGER")]#[ORM\JoinColumn(name:"user_status_code", referencedColumnName: "user_status_code", nullable: false)]private ?UserStatus $userStatus = null;#[ORM\Column(length: 2, nullable: true)]private ?string $gender = null;#[ORM\OneToOne(mappedBy: 'user', fetch:"EAGER", cascade: ['persist', 'remove'])]private ?UserDetail $userDetail = null;#[ORM\OneToMany(mappedBy: 'user', targetEntity: TeamMember::class)]private Collection $teamMembers;#[ORM\OneToMany(mappedBy: 'user', targetEntity: UserInvoice::class)]private Collection $userInvoices;#[ORM\Column(type:"datetime", nullable:true)]private $createdAt;#[ORM\Column(type:"datetime", nullable:true)]private $approvedAt;#[ORM\Column(type:"datetime", nullable:true)]private $validAt;#[ORM\OneToMany(mappedBy: 'user', targetEntity: EmailArchive::class)]private Collection $emailArchives;#[ORM\OneToMany(mappedBy: 'user', targetEntity: Payment::class)]private Collection $payments;#[ORM\OneToMany(mappedBy: 'user', targetEntity: PartyPillar::class)]private Collection $partyPillars;#[ORM\OneToMany(mappedBy: 'user', targetEntity: Donation::class)]private Collection $donations;public function __construct(){$this->userImages = new ArrayCollection();$this->teamMembers = new ArrayCollection();$this->userInvoices = new ArrayCollection();$this->emailArchives = new ArrayCollection();$this->payments = new ArrayCollection();$this->partyPillars = new ArrayCollection();$this->donations = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getEmail(): ?string{return $this->email;}public function setEmail(string $email): self{$this->email = $email;return $this;}/*** A visual identifier that represents this user.** @see UserInterface*/public function getUserIdentifier(): string{return (string) $this->email;}/*** @see UserInterface*/public function getRoles(): array{$roles = $this->roles;// guarantee every user at least has ROLE_USER$roles[] = 'ROLE_USER';return array_unique($roles);}public function setRoles(array $roles): self{$this->roles = (!empty($roles)) ?? self::ROLE_USER ;return $this;}/*** @see PasswordAuthenticatedUserInterface*/public function getPassword(): string{return $this->password;}public function setPassword(string $password): self{$this->password = $password;return $this;}/*** @see UserInterface*/public function eraseCredentials(){// If you store any temporary, sensitive data on the user, clear it here// $this->plainPassword = null;}public function getFirstName(): ?string{return $this->firstName;}public function setFirstName(string $firstName): self{$this->firstName = $firstName;return $this;}public function getLastName(): ?string{return $this->lastName;}public function setLastName(?string $lastName): self{$this->lastName = $lastName;return $this;}public function getAddress(): ?string{return $this->address;}public function setAddress(?string $address): self{$this->address = $address;return $this;}public function getPhoneNo(): ?string{return $this->phoneNo;}public function setPhoneNo(?string $phoneNo): self{$this->phoneNo = $phoneNo;return $this;}/*** @return Collection<int, UserImage>*/public function getUserImages(): Collection{return $this->userImages;}public function getUserImagesByuserImageTypeCode(string $userImageTypeCode){if (!empty($this->userImages)){foreach($this->getUserImages() as $userImage){if($userImage->getUserImageType()->getUserImageTypeCode() != $userImageTypeCode){continue;}return $userImage;}}return null;}public function getUserInvoiceByImageMetadata(?ImageMetadata $imageMetadata){if (!empty($this->userInvoices)){foreach($this->getUserInvoices() as $userInvoice){if($userInvoice->getInvoice()->getImageMetadata()->getImageMetadataUid() != $imageMetadata->getImageMetadataUid()){continue;}return $userInvoice;}}return null;}// public function addUserImageTypeCode(UserImage $userImageTypeCode): self// {// if (!$this->userImages->contains($userImageTypeCode)) {// $this->userImages->add($userImageTypeCode);// $userImageTypeCode->setUser($this);// }//// return $this;// }//// public function removeUserImageTypeCode(UserImage $userImageTypeCode): self// {// if ($this->userImages->removeElement($userImageTypeCode)) {// // set the owning side to null (unless already changed)// if ($userImageTypeCode->getUser() === $this) {// $userImageTypeCode->setUser(null);// }// }//// return $this;// }public function getUserStatus(): ?UserStatus{return $this->userStatus;}public function setUserStatus(?UserStatus $userStatus): static{$this->userStatus = $userStatus;return $this;}public function getGender(): ?string{return $this->gender;}public function setGender(?string $gender): static{$this->gender = $gender;return $this;}public function getUserDetail(): ?UserDetail{return $this->userDetail;}public function setUserDetail(?UserDetail $userDetail): static{// unset the owning side of the relation if necessaryif ($userDetail === null && $this->userDetail !== null) {$this->userDetail->setUser(null);}// set the owning side of the relation if necessaryif ($userDetail !== null && $userDetail->getUser() !== $this) {$userDetail->setUser($this);}$this->userDetail = $userDetail;return $this;}/*** @return Collection<int, TeamMember>*/public function getTeamMembers(): Collection{return $this->teamMembers;}public function getDisplayTeamMember():string {foreach ($this->teamMembers as $teamMember){return $teamMember->getDesignation()->getName(); //Fixme: TBD designation priority order}return "General Member";}public function addTeamMember(TeamMember $teamMember): static{if (!$this->teamMembers->contains($teamMember)) {$this->teamMembers->add($teamMember);$teamMember->setUser($this);}return $this;}public function removeTeamMember(TeamMember $teamMember): static{if ($this->teamMembers->removeElement($teamMember)) {// set the owning side to null (unless already changed)if ($teamMember->getUser() === $this) {$teamMember->setUser(null);}}return $this;}/*** @return Collection<int, UserInvoice>*/public function getUserInvoices(): Collection{return $this->userInvoices;}public function addUserInvoice(UserInvoice $userInvoice): static{if (!$this->userInvoices->contains($userInvoice)) {$this->userInvoices->add($userInvoice);$userInvoice->setUser($this);}return $this;}public function removeUserInvoice(UserInvoice $userInvoice): static{if ($this->userInvoices->removeElement($userInvoice)) {// set the owning side to null (unless already changed)if ($userInvoice->getUser() === $this) {$userInvoice->setUser(null);}}return $this;}/*** @return \DateTimeInterface*/public function getCreatedAt(): ?\DateTimeInterface{return $this->createdAt;}/*** @param mixed $createdAt*/public function setCreatedAt(? \DateTimeInterface $createdAt): self{$this->createdAt = $createdAt;return $this;}/*** @return mixed*/public function getApprovedAt(): ?\DateTimeInterface{return $this->approvedAt;}/*** @param mixed $approvedAt*/public function setApprovedAt(?\DateTimeInterface $approvedAt): self{$this->approvedAt = $approvedAt;return $this;}/*** @return mixed*/public function getValidAt(): ?\DateTimeInterface{return $this->validAt;}/*** @param mixed $validAt*/public function setValidAt($validAt): self{$this->validAt = $validAt;return $this;}/*** @return Collection<int, EmailArchive>*/public function getEmailArchives(): Collection{return $this->emailArchives;}public function addEmailArchive(EmailArchive $emailArchive): static{if (!$this->emailArchives->contains($emailArchive)) {$this->emailArchives->add($emailArchive);$emailArchive->setUser($this);}return $this;}public function removeEmailArchive(EmailArchive $emailArchive): static{if ($this->emailArchives->removeElement($emailArchive)) {// set the owning side to null (unless already changed)if ($emailArchive->getUser() === $this) {$emailArchive->setUser(null);}}return $this;}/*** @return Collection<int, Payment>*/public function getPayments(): Collection{return $this->payments;}public function addPayment(Payment $payment): static{if (!$this->payments->contains($payment)) {$this->payments->add($payment);$payment->setUser($this);}return $this;}public function removePayment(Payment $payment): static{if ($this->payments->removeElement($payment)) {// set the owning side to null (unless already changed)if ($payment->getUser() === $this) {$payment->setUser(null);}}return $this;}/*** @return Collection<int, PartyPillar>*/public function getPartyPillars(): Collection{return $this->partyPillars;}public function addPartyPillar(PartyPillar $partyPillar): static{if (!$this->partyPillars->contains($partyPillar)) {$this->partyPillars->add($partyPillar);$partyPillar->setUser($this);}return $this;}public function removePartyPillar(PartyPillar $partyPillar): static{if ($this->partyPillars->removeElement($partyPillar)) {// set the owning side to null (unless already changed)if ($partyPillar->getUser() === $this) {$partyPillar->setUser(null);}}return $this;}public function isPaid( string $paymentType):?int {foreach($this->getPayments() as $payment){if($payment->getPaymentType()->getPaymentTypeCode() == $paymentType&& $payment->getPaymentStatus()->getPaymentStatusCode() == PaymentStatus::STATUS_PAID){return $payment->getPaymentId();}}return null;}/*** @return Collection<int, Donation>*/public function getDonations(): Collection{return $this->donations;}public function addDonation(Donation $donation): static{if (!$this->donations->contains($donation)) {$this->donations->add($donation);$donation->setUser($this);}return $this;}public function removeDonation(Donation $donation): static{if ($this->donations->removeElement($donation)) {// set the owning side to null (unless already changed)if ($donation->getUser() === $this) {$donation->setUser(null);}}return $this;}}