<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @UniqueEntity("email")
* @UniqueEntity("username")
*/
class User implements UserInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $nom;
/**
* @ORM\Column(type="string", length=255)
*/
private $email;
/**
* @ORM\Column(type="string", length=255)
*/
private $password;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $country;
/**
* @ORM\OneToMany(targetEntity=Livre::class, mappedBy="user")
*/
private $livres;
/**
* @ORM\OneToMany(targetEntity=Demande::class, mappedBy="user")
*/
private $demandes;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $username;
/**
* @ORM\OneToMany(targetEntity=Favori::class, mappedBy="User")
*/
private $favoris;
/**
* @ORM\OneToMany(targetEntity=Notification::class, mappedBy="user")
*/
private $notifications;
public function __construct()
{
$this->livres = new ArrayCollection();
$this->demandes = new ArrayCollection();
$this->favoris = new ArrayCollection();
$this->notifications = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setNom(string $nom): self
{
$this->nom = $nom;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(?string $country): self
{
$this->country = $country;
return $this;
}
public function getUsername()
{
return $this->username;
}
public function eraseCredentials()
{
}
public function getSalt()
{
}
public function getRoles()
{
return ['ROLE_USER'];
}
public function getUserIdentifier(): string
{
return $this->getEmail();
}
/**
* @return Collection<int, Livre>
*/
public function getLivres(): Collection
{
return $this->livres;
}
public function addLivre(Livre $livre): self
{
if (!$this->livres->contains($livre)) {
$this->livres[] = $livre;
$livre->setUser($this);
}
return $this;
}
public function removeLivre(Livre $livre): self
{
if ($this->livres->removeElement($livre)) {
// set the owning side to null (unless already changed)
if ($livre->getUser() === $this) {
$livre->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Demande>
*/
public function getDemandes(): Collection
{
return $this->demandes;
}
public function addDemande(Demande $demande): self
{
if (!$this->demandes->contains($demande)) {
$this->demandes[] = $demande;
$demande->setUser($this);
}
return $this;
}
public function removeDemande(Demande $demande): self
{
if ($this->demandes->removeElement($demande)) {
// set the owning side to null (unless already changed)
if ($demande->getUser() === $this) {
$demande->setUser(null);
}
}
return $this;
}
public function setUsername(?string $username): self
{
$this->username = $username;
return $this;
}
/**
* @return Collection<int, Favori>
*/
public function getFavoris(): Collection
{
return $this->favoris;
}
public function addFavori(Favori $favori): self
{
if (!$this->favoris->contains($favori)) {
$this->favoris[] = $favori;
$favori->setUser($this);
}
return $this;
}
public function removeFavori(Favori $favori): self
{
if ($this->favoris->removeElement($favori)) {
// set the owning side to null (unless already changed)
if ($favori->getUser() === $this) {
$favori->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Notification>
*/
public function getNotifications(): Collection
{
return $this->notifications;
}
public function addNotification(Notification $notification): self
{
if (!$this->notifications->contains($notification)) {
$this->notifications[] = $notification;
$notification->setUser($this);
}
return $this;
}
public function removeNotification(Notification $notification): self
{
if ($this->notifications->removeElement($notification)) {
// set the owning side to null (unless already changed)
if ($notification->getUser() === $this) {
$notification->setUser(null);
}
}
return $this;
}
}