src/Entity/User.php line 13

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.  */
  10. class User implements UserInterfacePasswordAuthenticatedUserInterface
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=180,  nullable=false)
  20.      */
  21.     private $email;
  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="boolean")
  33.      */
  34.     private $isDeleted=false;
  35.     /**
  36.      * @ORM\Column(type="string", length=255, nullable=true)
  37.      */
  38.     private $firstName;
  39.         /**
  40.      * @ORM\Column(type="string", length=255, nullable=true)
  41.      */
  42.     private $lastName;
  43.     /**
  44.      * @ORM\Column(type="boolean", nullable=true)
  45.      */
  46.     private $etat;
  47.     /**
  48.      * @ORM\OneToOne(targetEntity=Membre::class, mappedBy="user", cascade={"persist", "remove"})
  49.      */
  50.     private $membre;
  51.     public function getId(): ?int
  52.     {
  53.         return $this->id;
  54.     }
  55.     public function getEmail(): ?string
  56.     {
  57.         return $this->email;
  58.     }
  59.     public function setEmail(string $email): self
  60.     {
  61.         $this->email $email;
  62.         return $this;
  63.     }
  64.     /**
  65.      * A visual identifier that represents this user.
  66.      *
  67.      * @see UserInterface
  68.      */
  69.     public function getUserIdentifier(): string
  70.     {
  71.         return (string) $this->email;
  72.     }
  73.  
  74.     /*
  75.     /**
  76.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  77.      *
  78.     public function getUsername(): string
  79.     {
  80.         return (string) $this->email;
  81.     }
  82.     */
  83.     
  84.     public function getIsDeleted(): ?bool
  85.     {
  86.         return $this->isDeleted;
  87.     }
  88.     public function setIsDeleted(bool $isDeleted): self
  89.     {
  90.         $this->isDeleted $isDeleted;
  91.         return $this;
  92.     }
  93.     public function getFirstName(): ?string
  94.     {
  95.         return $this->firstName;
  96.     }
  97.     public function setFirstName(string $firstName): self
  98.     {
  99.         $this->firstName $firstName;
  100.         return $this;
  101.     }
  102.     public function getLastName(): ?string
  103.     {
  104.         return $this->lastName;
  105.     }
  106.     public function setLastName(string $lastName): self
  107.     {
  108.         $this->lastName $lastName;
  109.         return $this;
  110.     }
  111.     public function getUsername(): ?string
  112.     {
  113.         return $this->lastName.' '.$this->firstName;
  114.     }
  115.     /**
  116.      * @see UserInterface
  117.      */
  118.     public function getRoles(): array
  119.     {
  120.         $roles $this->roles;
  121.         // guarantee every user at least has ROLE_USER
  122.         $roles[] = 'ROLE_USER';
  123.         return array_unique($roles);
  124.     }
  125.     public function setRoles(array $roles): self
  126.     {
  127.         $this->roles $roles;
  128.         return $this;
  129.     }
  130.     /**
  131.      * @see PasswordAuthenticatedUserInterface
  132.      */
  133.     public function getPassword(): string
  134.     {
  135.         return $this->password;
  136.     }
  137.     public function setPassword(string $password): self
  138.     {
  139.         $this->password $password;
  140.         return $this;
  141.     }
  142.     /**
  143.      * Returning a salt is only needed, if you are not using a modern
  144.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  145.      *
  146.      * @see UserInterface
  147.      */
  148.     public function getSalt(): ?string
  149.     {
  150.         return null;
  151.     }
  152.     /**
  153.      * @see UserInterface
  154.      */
  155.     public function eraseCredentials()
  156.     {
  157.         // If you store any temporary, sensitive data on the user, clear it here
  158.         // $this->plainPassword = null;
  159.     }
  160.     public function isIsDeleted(): ?bool
  161.     {
  162.         return $this->isDeleted;
  163.     }
  164.     public function isEtat(): ?bool
  165.     {
  166.         return $this->etat;
  167.     }
  168.     public function setEtat(?bool $etat): self
  169.     {
  170.         $this->etat $etat;
  171.         return $this;
  172.     }
  173.     public function getMembre(): ?Membre
  174.     {
  175.         return $this->membre;
  176.     }
  177.     public function setMembre(Membre $membre): self
  178.     {
  179.         // set the owning side of the relation if necessary
  180.         if ($membre->getUser() !== $this) {
  181.             $membre->setUser($this);
  182.         }
  183.         $this->membre $membre;
  184.         return $this;
  185.     }
  186. }