src/Entity/User.php line 15

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\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. #[ORM\Entity(repositoryClassUserRepository::class)]
  11. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  12. class User implements UserInterfacePasswordAuthenticatedUserInterface
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\Column(length180uniquetrue)]
  19.     private ?string $email null;
  20.     #[ORM\Column]
  21.     private array $roles = [];
  22.     /**
  23.      * @var string The hashed password
  24.      */
  25.     #[ORM\Column]
  26.     private ?string $password null;
  27.     #[ORM\Column(length255nullabletrue)]
  28.     private ?string $nom null;
  29.     #[ORM\Column(length255nullabletrue)]
  30.     private ?string $prenom null;
  31.     #[ORM\Column(length255nullabletrue)]
  32.     private ?string $address null;
  33.     #[ORM\Column(length255nullabletrue)]
  34.     private ?string $telphone null;
  35.     #[ORM\Column(length255nullabletrue)]
  36.     private ?string $photo null;
  37.     #[ORM\Column(length255nullabletrue)]
  38.     private ?string $photocov null;
  39.     #[ORM\OneToMany(targetEntityTrace::class, mappedBy'user')]
  40.     private Collection $user;
  41.     public function __construct()
  42.     {
  43.         $this->user = new ArrayCollection();
  44.     }
  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): static
  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): static
  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): static
  90.     {
  91.         $this->password $password;
  92.         return $this;
  93.     }
  94.     /**
  95.      * @see UserInterface
  96.      */
  97.     public function eraseCredentials(): void
  98.     {
  99.         // If you store any temporary, sensitive data on the user, clear it here
  100.         // $this->plainPassword = null;
  101.     }
  102.     public function getNom(): ?string
  103.     {
  104.         return $this->nom;
  105.     }
  106.     public function setNom(?string $nom): static
  107.     {
  108.         $this->nom $nom;
  109.         return $this;
  110.     }
  111.     public function getPrenom(): ?string
  112.     {
  113.         return $this->prenom;
  114.     }
  115.     public function setPrenom(?string $prenom): static
  116.     {
  117.         $this->prenom $prenom;
  118.         return $this;
  119.     }
  120.     public function getAddress(): ?string
  121.     {
  122.         return $this->address;
  123.     }
  124.     public function setAddress(?string $address): static
  125.     {
  126.         $this->address $address;
  127.         return $this;
  128.     }
  129.     public function getTelphone(): ?string
  130.     {
  131.         return $this->telphone;
  132.     }
  133.     public function setTelphone(?string $telphone): static
  134.     {
  135.         $this->telphone $telphone;
  136.         return $this;
  137.     }
  138.     public function getPhoto(): ?string
  139.     {
  140.         return $this->photo;
  141.     }
  142.     public function setPhoto(?string $photo): static
  143.     {
  144.         $this->photo $photo;
  145.         return $this;
  146.     }
  147.     public function getPhotocov(): ?string
  148.     {
  149.         return $this->photocov;
  150.     }
  151.     public function setPhotocov(?string $photocov): static
  152.     {
  153.         $this->photocov $photocov;
  154.         return $this;
  155.     }
  156.     /**
  157.      * @return Collection<int, Trace>
  158.      */
  159.     public function getUser(): Collection
  160.     {
  161.         return $this->user;
  162.     }
  163.     public function addUser(Trace $user): static
  164.     {
  165.         if (!$this->user->contains($user)) {
  166.             $this->user->add($user);
  167.             $user->setUser($this);
  168.         }
  169.         return $this;
  170.     }
  171.     public function removeUser(Trace $user): static
  172.     {
  173.         if ($this->user->removeElement($user)) {
  174.             // set the owning side to null (unless already changed)
  175.             if ($user->getUser() === $this) {
  176.                 $user->setUser(null);
  177.             }
  178.         }
  179.         return $this;
  180.     }
  181. }