src/Entity/User.php line 14

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. #[ORM\Table(name'`user`')]
  11. class User implements UserInterfacePasswordAuthenticatedUserInterface
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type'integer')]
  16.     private $id;
  17.     #[ORM\Column(type'string'length180uniquetrue)]
  18.     private $email;
  19.     #[ORM\Column(type'json')]
  20.     private $roles = [];
  21.     #[ORM\Column(type'string')]
  22.     private $password;
  23.     #[ORM\Column(type'string'length255)]
  24.     private $firstname;
  25.     #[ORM\Column(type'string'length255)]
  26.     private $lastname;
  27.     #[ORM\Column(type'text'nullabletrue)]
  28.     private $fonctions;
  29.     #[ORM\OneToMany(mappedBy'user'targetEntityRequest::class)]
  30.     private $requests;
  31.     #[ORM\OneToMany(mappedBy'user',  targetEntityRequestResponse::class)]
  32.     private $requestResponses;
  33.     #[ORM\ManyToMany(targetEntityCategory::class, inversedBy'users')]
  34.     private $category;
  35.     #[ORM\OneToMany(mappedBy'user'targetEntitySeance::class)]
  36.     private $seances;
  37.     #[ORM\OneToMany(mappedBy'user'targetEntityExercice::class)]
  38.     private $exercices;
  39.     #[ORM\Column(type'string'length255nullabletrue)]
  40.     private $photo;
  41.     #[ORM\ManyToOne(targetEntityClub::class, inversedBy'users')]
  42.     private $club;
  43.     public function __construct()
  44.     {
  45.         $this->requests = new ArrayCollection();
  46.         $this->requestResponses = new ArrayCollection();
  47.         $this->category = new ArrayCollection();
  48.         $this->seances = new ArrayCollection();
  49.         $this->exercices = new ArrayCollection();
  50.     }
  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.      * @see UserInterface
  75.      */
  76.     public function getRoles(): array
  77.     {
  78.         $roles $this->roles;
  79.         // guarantee every user at least has ROLE_USER
  80.         $roles[] = 'ROLE_USER';
  81.         return array_unique($roles);
  82.     }
  83.     public function setRoles(array $roles): self
  84.     {
  85.         $this->roles $roles;
  86.         return $this;
  87.     }
  88.     /**
  89.      * @see PasswordAuthenticatedUserInterface
  90.      */
  91.     public function getPassword(): string
  92.     {
  93.         return $this->password;
  94.     }
  95.     public function setPassword(string $password): self
  96.     {
  97.         $this->password $password;
  98.         return $this;
  99.     }
  100.     /**
  101.      * @see UserInterface
  102.      */
  103.     public function eraseCredentials()
  104.     {
  105.         // If you store any temporary, sensitive data on the user, clear it here
  106.         // $this->plainPassword = null;
  107.     }
  108.     public function getFirstname(): ?string
  109.     {
  110.         return $this->firstname;
  111.     }
  112.     public function setFirstname(string $firstname): self
  113.     {
  114.         $this->firstname $firstname;
  115.         return $this;
  116.     }
  117.     public function getLastname(): ?string
  118.     {
  119.         return $this->lastname;
  120.     }
  121.     public function setLastname(string $lastname): self
  122.     {
  123.         $this->lastname $lastname;
  124.         return $this;
  125.     }
  126.     public function getFonctions(): ?string
  127.     {
  128.         return $this->fonctions;
  129.     }
  130.     public function setFonctions(?string $fonctions): self
  131.     {
  132.         $this->fonctions $fonctions;
  133.         return $this;
  134.     }
  135.     /**
  136.      * @return Collection|Request[]
  137.      */
  138.     public function getRequests(): Collection
  139.     {
  140.         return $this->requests;
  141.     }
  142.     public function addRequest(Request $request): self
  143.     {
  144.         if (!$this->requests->contains($request)) {
  145.             $this->requests[] = $request;
  146.             $request->setUser($this);
  147.         }
  148.         return $this;
  149.     }
  150.     public function removeRequest(Request $request): self
  151.     {
  152.         if ($this->requests->removeElement($request)) {
  153.             // set the owning side to null (unless already changed)
  154.             if ($request->getUser() === $this) {
  155.                 $request->setUser(null);
  156.             }
  157.         }
  158.         return $this;
  159.     }
  160.     /**
  161.      * @return Collection|RequestResponse[]
  162.      */
  163.     public function getRequestResponses(): Collection
  164.     {
  165.         return $this->requestResponses;
  166.     }
  167.     public function addRequestResponse(RequestResponse $requestResponse): self
  168.     {
  169.         if (!$this->requestResponses->contains($requestResponse)) {
  170.             $this->requestResponses[] = $requestResponse;
  171.             $requestResponse->setUser($this);
  172.         }
  173.         return $this;
  174.     }
  175.     public function removeRequestResponse(RequestResponse $requestResponse): self
  176.     {
  177.         if ($this->requestResponses->removeElement($requestResponse)) {
  178.             // set the owning side to null (unless already changed)
  179.             if ($requestResponse->getUser() === $this) {
  180.                 $requestResponse->setUser(null);
  181.             }
  182.         }
  183.         return $this;
  184.     }
  185.     /**
  186.      * @return Collection|Category[]
  187.      */
  188.     public function getCategory(): Collection
  189.     {
  190.         return $this->category;
  191.     }
  192.     public function addCategory(Category $category): self
  193.     {
  194.         if (!$this->category->contains($category)) {
  195.             $this->category[] = $category;
  196.         }
  197.         return $this;
  198.     }
  199.     public function removeCategory(Category $category): self
  200.     {
  201.         $this->category->removeElement($category);
  202.         return $this;
  203.     }
  204.     /**
  205.      * @return Collection|Seance[]
  206.      */
  207.     public function getSeances(): Collection
  208.     {
  209.         return $this->seances;
  210.     }
  211.     public function addSeance(Seance $seance): self
  212.     {
  213.         if (!$this->seances->contains($seance)) {
  214.             $this->seances[] = $seance;
  215.             $seance->setUser($this);
  216.         }
  217.         return $this;
  218.     }
  219.     public function removeSeance(Seance $seance): self
  220.     {
  221.         if ($this->seances->removeElement($seance)) {
  222.             // set the owning side to null (unless already changed)
  223.             if ($seance->getUser() === $this) {
  224.                 $seance->setUser(null);
  225.             }
  226.         }
  227.         return $this;
  228.     }
  229.     /**
  230.      * @return Collection|Exercice[]
  231.      */
  232.     public function getExercices(): Collection
  233.     {
  234.         return $this->exercices;
  235.     }
  236.     public function addExercice(Exercice $exercice): self
  237.     {
  238.         if (!$this->exercices->contains($exercice)) {
  239.             $this->exercices[] = $exercice;
  240.             $exercice->setUser($this);
  241.         }
  242.         return $this;
  243.     }
  244.     public function removeExercice(Exercice $exercice): self
  245.     {
  246.         if ($this->exercices->removeElement($exercice)) {
  247.             // set the owning side to null (unless already changed)
  248.             if ($exercice->getUser() === $this) {
  249.                 $exercice->setUser(null);
  250.             }
  251.         }
  252.         return $this;
  253.     }
  254.     public function getPhoto(): ?string
  255.     {
  256.         return $this->photo;
  257.     }
  258.     public function setPhoto(?string $photo): self
  259.     {
  260.         $this->photo $photo;
  261.         return $this;
  262.     }
  263.     public function getClub(): ?Club
  264.     {
  265.         return $this->club;
  266.     }
  267.     public function setClub(?Club $club): self
  268.     {
  269.         $this->club $club;
  270.         return $this;
  271.     }
  272. }