<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\Table(name: '`user`')]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 180, unique: true)]
private $email;
#[ORM\Column(type: 'json')]
private $roles = [];
#[ORM\Column(type: 'string')]
private $password;
#[ORM\Column(type: 'string', length: 255)]
private $firstname;
#[ORM\Column(type: 'string', length: 255)]
private $lastname;
#[ORM\Column(type: 'text', nullable: true)]
private $fonctions;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Request::class)]
private $requests;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: RequestResponse::class)]
private $requestResponses;
#[ORM\ManyToMany(targetEntity: Category::class, inversedBy: 'users')]
private $category;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Seance::class)]
private $seances;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Exercice::class)]
private $exercices;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $photo;
#[ORM\ManyToOne(targetEntity: Club::class, inversedBy: 'users')]
private $club;
public function __construct()
{
$this->requests = new ArrayCollection();
$this->requestResponses = new ArrayCollection();
$this->category = new ArrayCollection();
$this->seances = new ArrayCollection();
$this->exercices = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->email;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(string $firstname): self
{
$this->firstname = $firstname;
return $this;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(string $lastname): self
{
$this->lastname = $lastname;
return $this;
}
public function getFonctions(): ?string
{
return $this->fonctions;
}
public function setFonctions(?string $fonctions): self
{
$this->fonctions = $fonctions;
return $this;
}
/**
* @return Collection|Request[]
*/
public function getRequests(): Collection
{
return $this->requests;
}
public function addRequest(Request $request): self
{
if (!$this->requests->contains($request)) {
$this->requests[] = $request;
$request->setUser($this);
}
return $this;
}
public function removeRequest(Request $request): self
{
if ($this->requests->removeElement($request)) {
// set the owning side to null (unless already changed)
if ($request->getUser() === $this) {
$request->setUser(null);
}
}
return $this;
}
/**
* @return Collection|RequestResponse[]
*/
public function getRequestResponses(): Collection
{
return $this->requestResponses;
}
public function addRequestResponse(RequestResponse $requestResponse): self
{
if (!$this->requestResponses->contains($requestResponse)) {
$this->requestResponses[] = $requestResponse;
$requestResponse->setUser($this);
}
return $this;
}
public function removeRequestResponse(RequestResponse $requestResponse): self
{
if ($this->requestResponses->removeElement($requestResponse)) {
// set the owning side to null (unless already changed)
if ($requestResponse->getUser() === $this) {
$requestResponse->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Category[]
*/
public function getCategory(): Collection
{
return $this->category;
}
public function addCategory(Category $category): self
{
if (!$this->category->contains($category)) {
$this->category[] = $category;
}
return $this;
}
public function removeCategory(Category $category): self
{
$this->category->removeElement($category);
return $this;
}
/**
* @return Collection|Seance[]
*/
public function getSeances(): Collection
{
return $this->seances;
}
public function addSeance(Seance $seance): self
{
if (!$this->seances->contains($seance)) {
$this->seances[] = $seance;
$seance->setUser($this);
}
return $this;
}
public function removeSeance(Seance $seance): self
{
if ($this->seances->removeElement($seance)) {
// set the owning side to null (unless already changed)
if ($seance->getUser() === $this) {
$seance->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Exercice[]
*/
public function getExercices(): Collection
{
return $this->exercices;
}
public function addExercice(Exercice $exercice): self
{
if (!$this->exercices->contains($exercice)) {
$this->exercices[] = $exercice;
$exercice->setUser($this);
}
return $this;
}
public function removeExercice(Exercice $exercice): self
{
if ($this->exercices->removeElement($exercice)) {
// set the owning side to null (unless already changed)
if ($exercice->getUser() === $this) {
$exercice->setUser(null);
}
}
return $this;
}
public function getPhoto(): ?string
{
return $this->photo;
}
public function setPhoto(?string $photo): self
{
$this->photo = $photo;
return $this;
}
public function getClub(): ?Club
{
return $this->club;
}
public function setClub(?Club $club): self
{
$this->club = $club;
return $this;
}
}