src/Entity/UserStatus.php line 12

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserStatusRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassUserStatusRepository::class)]
  9. class UserStatus
  10. {
  11.     const STATUS_ACTIVE 'AC';
  12.     const STATUS_DISABLED 'DS';
  13.     const STATUS_IDENTITY_REQUIRED 'IR';
  14.     const STATUS_PAYMENT_AND_IDENTITY_REQUIRED 'PI';
  15.     const STATUS_PAYMENT_REQUIRED 'PR';
  16.     const STATUS_PENDING 'PA';
  17.     const STATUS_REJECTED 'RJ';
  18.     const STATUS_WAITING_RENEW 'RN';
  19.     const STATUS_WITHDRAW_MEMBERSHIP 'WM';
  20.     const STATUS_EXPIRED 'EX';
  21.     #[ORM\Id]
  22.     #[ORM\GeneratedValue]
  23.     #[ORM\Column(length2)]
  24.     private ?string $userStatusCode null;
  25.     #[ORM\Column(length255)]
  26.     private ?string $name null;
  27.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  28.     private ?\DateTimeInterface $updated null;
  29.     #[ORM\Column]
  30.     private ?int $updatedBy null;
  31.     #[ORM\OneToMany(mappedBy'userStatus'targetEntityUser::class)]
  32.     #[ORM\JoinColumn(name:"user_status_code"referencedColumnName"user_status_code")]
  33.     private Collection $users;
  34.     public function __construct()
  35.     {
  36.         $this->users = new ArrayCollection();
  37.     }
  38.     public function getUserStatusCode(): ?string
  39.     {
  40.         return $this->userStatusCode;
  41.     }
  42.     public function setUserStatusCode(string $userStatusCode): static
  43.     {
  44.         $this->userStatusCode $userStatusCode;
  45.         return $this;
  46.     }
  47.     public function getName(): ?string
  48.     {
  49.         return $this->name;
  50.     }
  51.     public function setName(string $name): static
  52.     {
  53.         $this->name $name;
  54.         return $this;
  55.     }
  56.     public function getUpdated(): ?\DateTimeInterface
  57.     {
  58.         return $this->updated;
  59.     }
  60.     public function setUpdated(\DateTimeInterface $updated): static
  61.     {
  62.         $this->updated $updated;
  63.         return $this;
  64.     }
  65.     public function getUpdatedBy(): ?int
  66.     {
  67.         return $this->updatedBy;
  68.     }
  69.     public function setUpdatedBy(int $updatedBy): static
  70.     {
  71.         $this->updatedBy $updatedBy;
  72.         return $this;
  73.     }
  74.     /**
  75.      * @return Collection<int, User>
  76.      */
  77.     public function getUsers(): Collection
  78.     {
  79.         return $this->users;
  80.     }
  81.     public function addUser(User $user): static
  82.     {
  83.         if (!$this->users->contains($user)) {
  84.             $this->users->add($user);
  85.             $user->setUserStatus($this);
  86.         }
  87.         return $this;
  88.     }
  89.     public function removeUser(User $user): static
  90.     {
  91.         if ($this->users->removeElement($user)) {
  92.             // set the owning side to null (unless already changed)
  93.             if ($user->getUserStatus() === $this) {
  94.                 $user->setUserStatus(null);
  95.             }
  96.         }
  97.         return $this;
  98.     }
  99. }