src/Entity/User.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. #[ORM\Entity(repositoryClassUserRepository::class)]
  10. class User implements UserInterfacePasswordAuthenticatedUserInterface
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length180uniquetrue)]
  17.     private ?string $email null;
  18.     #[ORM\Column]
  19.     private array $roles = [];
  20.     /**
  21.      * @var string The hashed password
  22.      */
  23.     #[ORM\Column]
  24.     private ?string $password null;
  25.     #[ORM\Column(length255nullabletrue)]
  26.     private ?string $nom null;
  27.     #[ORM\Column(length255nullabletrue)]
  28.     private ?string $prenom null;
  29.     #[ORM\Column(nullabletrue)]
  30.     private ?int $telephone null;
  31.     #[ORM\Column(length255nullabletrue)]
  32.     private ?string $fonction null;
  33.     #[ORM\OneToMany(targetEntityBail::class, mappedBy'user')]
  34.     private Collection $bails;
  35.     public function __construct()
  36.     {
  37.         $this->bails = new ArrayCollection();
  38.     }
  39.     public function getId(): ?int
  40.     {
  41.         return $this->id;
  42.     }
  43.     public function getEmail(): ?string
  44.     {
  45.         return $this->email;
  46.     }
  47.     public function setEmail(string $email): static
  48.     {
  49.         $this->email $email;
  50.         return $this;
  51.     }
  52.     /**
  53.      * A visual identifier that represents this user.
  54.      *
  55.      * @see UserInterface
  56.      */
  57.     public function getUserIdentifier(): string
  58.     {
  59.         return (string) $this->email;
  60.     }
  61.     /**
  62.      * @see UserInterface
  63.      */
  64.     public function getRoles(): array
  65.     {
  66.         $roles $this->roles;
  67.         // guarantee every user at least has ROLE_USER
  68.         $roles[] = 'ROLE_AGENT';
  69.         return array_unique($roles);
  70.     }
  71.     public function setRoles(array $roles): static
  72.     {
  73.         $this->roles $roles;
  74.         return $this;
  75.     }
  76.     /**
  77.      * @see PasswordAuthenticatedUserInterface
  78.      */
  79.     public function getPassword(): string
  80.     {
  81.         return $this->password;
  82.     }
  83.     public function setPassword(string $password): static
  84.     {
  85.         $this->password $password;
  86.         return $this;
  87.     }
  88.     /**
  89.      * @see UserInterface
  90.      */
  91.     public function eraseCredentials(): void
  92.     {
  93.         // If you store any temporary, sensitive data on the user, clear it here
  94.         // $this->plainPassword = null;
  95.     }
  96.     public function getNom(): ?string
  97.     {
  98.         return $this->nom;
  99.     }
  100.     public function setNom(?string $nom): static
  101.     {
  102.         $this->nom $nom;
  103.         return $this;
  104.     }
  105.     public function getPrenom(): ?string
  106.     {
  107.         return $this->prenom;
  108.     }
  109.     public function setPrenom(?string $prenom): static
  110.     {
  111.         $this->prenom $prenom;
  112.         return $this;
  113.     }
  114.     public function getTelephone(): ?int
  115.     {
  116.         return $this->telephone;
  117.     }
  118.     public function setTelephone(?int $telephone): static
  119.     {
  120.         $this->telephone $telephone;
  121.         return $this;
  122.     }
  123.     public function getFonction(): ?string
  124.     {
  125.         return $this->fonction;
  126.     }
  127.     public function setFonction(?string $fonction): static
  128.     {
  129.         $this->fonction $fonction;
  130.         return $this;
  131.     }
  132.     /**
  133.      * @return Collection<int, Bail>
  134.      */
  135.     public function getBails(): Collection
  136.     {
  137.         return $this->bails;
  138.     }
  139.     public function addBail(Bail $bail): static
  140.     {
  141.         if (!$this->bails->contains($bail)) {
  142.             $this->bails->add($bail);
  143.             $bail->setUser($this);
  144.         }
  145.         return $this;
  146.     }
  147.     public function removeBail(Bail $bail): static
  148.     {
  149.         if ($this->bails->removeElement($bail)) {
  150.             // set the owning side to null (unless already changed)
  151.             if ($bail->getUser() === $this) {
  152.                 $bail->setUser(null);
  153.             }
  154.         }
  155.         return $this;
  156.     }
  157. }