src\Entity\User.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  6. use Symfony\Component\Security\Core\User\UserInterface;
  7. /**
  8.  * @ORM\Entity(repositoryClass=UserRepository::class)
  9.  * @ORM\Table(name = "neema.`user`")
  10.  */
  11. class User implements UserInterfacePasswordAuthenticatedUserInterface {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=180, unique=true)
  20.      */
  21.     private $phone;
  22.     /**
  23.      * @ORM\Column(type="json")
  24.      */
  25.     private $roles = [];
  26.     /**
  27.      * @var string The hashed password
  28.      * @ORM\Column(type="string")
  29.      */
  30.     private $password;
  31.     /**
  32.      * @ORM\Column(type="datetime")
  33.      */
  34.     private $createdAt;
  35.     /**
  36.      * @ORM\ManyToOne(targetEntity=Branch::class)
  37.      * @ORM\JoinColumn(nullable=false)
  38.      */
  39.     private $branch;
  40.     /**
  41.      * @ORM\ManyToOne(targetEntity=SystemUser::class)
  42.      * @ORM\JoinColumn(nullable=false)
  43.      */
  44.     private $systemUser;
  45.     /**
  46.      * @ORM\Column(type="boolean")
  47.      */
  48.     private $isActive;
  49.     public function getId(): ?int
  50.     {
  51.         return $this->id;
  52.     }
  53.     public function getPhone(): ?string
  54.     {
  55.         return $this->phone;
  56.     }
  57.     public function setPhone(string $phone): self
  58.     {
  59.         $this->phone $phone;
  60.         return $this;
  61.     }
  62.     /**
  63.      * A visual identifier that represents this user.
  64.      *
  65.      * @see UserInterface
  66.      */
  67.     public function getUserIdentifier(): string
  68.     {
  69.         return (string) $this->phone;
  70.     }
  71.     /**
  72.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  73.      */
  74.     public function getUsername(): string
  75.     {
  76.         return (string) $this->phone;
  77.     }
  78.     /**
  79.      * @see UserInterface
  80.      */
  81.     public function getRoles(): array
  82.     {
  83.         $roles $this->roles;
  84.         // guarantee every user at least has ROLE_USER
  85. //        $roles[] = 'ROLE_USER';
  86.         return array_unique($roles);
  87.     }
  88.     public function setRoles(array $roles): self
  89.     {
  90.         $this->roles $roles;
  91.         return $this;
  92.     }
  93.     /**
  94.      * @see PasswordAuthenticatedUserInterface
  95.      */
  96.     public function getPassword(): string
  97.     {
  98.         return $this->password;
  99.     }
  100.     public function setPassword(string $password): self
  101.     {
  102.         $this->password $password;
  103.         return $this;
  104.     }
  105.     /**
  106.      * Returning a salt is only needed, if you are not using a modern
  107.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  108.      *
  109.      * @see UserInterface
  110.      */
  111.     public function getSalt(): ?string
  112.     {
  113.         return null;
  114.     }
  115.     /**
  116.      * @see UserInterface
  117.      */
  118.     public function eraseCredentials()
  119.     {
  120.         // If you store any temporary, sensitive data on the user, clear it here
  121.         // $this->plainPassword = null;
  122.     }
  123.     public function getCreatedAt(): ?\DateTimeInterface
  124.     {
  125.         return $this->createdAt;
  126.     }
  127.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  128.     {
  129.         $this->createdAt $createdAt;
  130.         return $this;
  131.     }
  132.     public function getBranch(): ?Branch
  133.     {
  134.         return $this->branch;
  135.     }
  136.     public function setBranch(?Branch $branch): self
  137.     {
  138.         $this->branch $branch;
  139.         return $this;
  140.     }
  141.     public function getSystemUser(): ?SystemUser
  142.     {
  143.         return $this->systemUser;
  144.     }
  145.     public function setSystemUser(?SystemUser $systemUser): self
  146.     {
  147.         $this->systemUser $systemUser;
  148.         return $this;
  149.     }
  150.     /**
  151.      * @return mixed
  152.      */
  153.     public function getIsActive()
  154.     {
  155.         return $this->isActive;
  156.     }
  157.     /**
  158.      * @param mixed $isActive
  159.      */
  160.     public function setIsActive($isActive): void
  161.     {
  162.         $this->isActive $isActive;
  163.     }
  164.     public function __toString()
  165.     {
  166.         // TODO: Implement __toString() method.
  167.         return $this->getPhone();
  168.     }
  169. }