src/Entity/User.php line 16

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\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  6. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. /**
  9.  * @ORM\Entity(repositoryClass=UserRepository::class)
  10.  * @ORM\Table(name="ogresto.user")
  11.  */
  12. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  13. class User implements UserInterfacePasswordAuthenticatedUserInterface
  14. {
  15.     /**
  16.      * 
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=180, unique=true)
  24.      */
  25.     private $email;
  26.     /**
  27.      * @ORM\Column(type="json")
  28.      */
  29.     private $roles = [];
  30.     /**
  31.      * @var string The hashed password
  32.      * @ORM\Column(type="string")
  33.      */
  34.     private $password;
  35.     /**
  36.      * 
  37.      * @ORM\Column(name="name", type="string", length=5000,nullable=true)
  38.      */
  39.     private $name;
  40.     /**
  41.      * @ORM\Column(name="first_name", type="string",length=5000,nullable=true)
  42.      * 
  43.      */
  44.     private $firstName;
  45.     public function getId(): ?int
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function getEmail(): ?string
  50.     {
  51.         return $this->email;
  52.     }
  53.     public function setEmail(string $email): self
  54.     {
  55.         $this->email $email;
  56.         return $this;
  57.     }
  58.     /**
  59.      * A visual identifier that represents this user.
  60.      *
  61.      * @see UserInterface
  62.      */
  63.     public function getUserIdentifier(): string
  64.     {
  65.         return (string) $this->email;
  66.     }
  67.     /**
  68.      * @see UserInterface
  69.      */
  70.     public function getRoles(): array
  71.     {
  72.         $roles $this->roles;
  73.         // guarantee every user at least has ROLE_USER
  74.         $roles[] = 'ROLE_USER';
  75.         return array_unique($roles);
  76.     }
  77.     public function setRoles(array $roles): self
  78.     {
  79.         $this->roles $roles;
  80.         return $this;
  81.     }
  82.     /**
  83.      * @see PasswordAuthenticatedUserInterface
  84.      */
  85.     public function getPassword(): string
  86.     {
  87.         return $this->password;
  88.     }
  89.     public function setPassword(string $password): self
  90.     {
  91.         $this->password $password;
  92.         return $this;
  93.     }
  94.     /**
  95.      * @see UserInterface
  96.      */
  97.     public function eraseCredentials()
  98.     {
  99.         // If you store any temporary, sensitive data on the user, clear it here
  100.         // $this->plainPassword = null;
  101.     }
  102.     public function getSalt()
  103.     {
  104.         
  105.     }
  106.     public function getUsername()
  107.     {
  108.         return $this->name;
  109.     }
  110.     public function setUsername($name){
  111.       $this->name=$name;
  112.       return $this;
  113.     }
  114.     public function setFirstname($firstName){
  115.         $this->firstName=$firstName;
  116.         return $this;
  117.     }
  118.     public function getFirstname(){
  119.         return $this->firstName;
  120.     }
  121.     public function getName(): ?string
  122.     {
  123.         return $this->name;
  124.     }
  125.     public function setName(?string $name): self
  126.     {
  127.         $this->name $name;
  128.         return $this;
  129.     }
  130. }
  131.