- <?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\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
- use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
- use Symfony\Component\Security\Core\User\UserInterface;
- 
- #[ORM\Entity(repositoryClass: UserRepository::class)]
- #[ORM\Table(name: '`user`')]
- #[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')]
- class User implements UserInterface, PasswordAuthenticatedUserInterface
- {
-     #[ORM\Id]
-     #[ORM\GeneratedValue]
-     #[ORM\Column]
-     private ?int $id = null;
- 
-     #[ORM\Column(length: 180, unique: true)]
-     private ?string $email = null;
- 
-     #[ORM\Column]
-     private array $roles = [''];
- 
-     //private array $roles = ['ROLE_USER']; Permet d'ajouter que des utilisateurs
- 
-     /**
-      * @var string The hashed password
-      */
-     #[ORM\Column]
-     private ?string $password = null;
- 
-     #[ORM\Column(length: 255)]
-     private ?string $nom = null;
- 
-     #[ORM\Column(length: 255)]
-     private ?string $prenom = null;
- 
-     #[ORM\Column(length: 255)]
-     private ?string $poste = null;
- 
-     #[ORM\Column(length: 255, nullable: true)]
-     private ?string $description = null;
- 
-     #[ORM\Column(length: 255, nullable: true)]
-     private ?string $linkedin = null;
- 
-     #[ORM\Column(length: 255, nullable: true)]
-     private ?string $facebook = null;
- 
-     #[ORM\Column(length: 255, nullable: true)]
-     private ?string $instagram = null;
- 
-     #[ORM\Column(length: 255, nullable: true)]
-     private ?string $twitter = null;
- 
-     #[ORM\Column(length: 255, nullable: true)]
-     private ?string $lien = null;
- 
-     #[ORM\Column(length: 255)]
-     private ?string $image_profil = null;
- 
-     #[ORM\Column(length: 255)]
-     private ?string $image_profil_alt = null;
- 
-     #[ORM\Column(length: 255)]
-     private ?string $image_bandeau = null;
- 
-     #[ORM\Column(length: 255)]
-     private ?string $image_bandeau_alt = null;
- 
-     #[ORM\Column]
-     private ?\DateTimeImmutable $created_at = null;
- 
-     #[ORM\ManyToOne(inversedBy: 'users')]
-     #[ORM\JoinColumn(nullable: false)]
-     private ?Chocolaterie $chocolaterie = null;
- 
-     #[ORM\OneToMany(mappedBy: 'user', targetEntity: Like::class, orphanRemoval: true)]
-     private Collection $likes;
- 
-     #[ORM\OneToMany(mappedBy: 'user', targetEntity: Commentaire::class, orphanRemoval: true)]
-     private Collection $commentaires;
- 
-     #[ORM\OneToMany(mappedBy: 'user', targetEntity: Post::class, orphanRemoval: true)]
-     private Collection $posts;
- 
-     public function __construct()
-     {
-         $this->likes = new ArrayCollection();
-         $this->commentaires = new ArrayCollection();
-         $this->posts = 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 getNom(): ?string
-     {
-         return $this->nom;
-     }
- 
-     public function setNom(string $nom): self
-     {
-         $this->nom = $nom;
- 
-         return $this;
-     }
- 
-     public function getPrenom(): ?string
-     {
-         return $this->prenom;
-     }
- 
-     public function setPrenom(string $prenom): self
-     {
-         $this->prenom = $prenom;
- 
-         return $this;
-     }
- 
-     public function getPoste(): ?string
-     {
-         return $this->poste;
-     }
- 
-     public function setPoste(string $poste): self
-     {
-         $this->poste = $poste;
- 
-         return $this;
-     }
- 
-     public function getDescription(): ?string
-     {
-         return $this->description;
-     }
- 
-     public function setDescription(?string $description): self
-     {
-         $this->description = $description;
- 
-         return $this;
-     }
- 
-     public function getLinkedin(): ?string
-     {
-         return $this->linkedin;
-     }
- 
-     public function setLinkedin(?string $linkedin): self
-     {
-         $this->linkedin = $linkedin;
- 
-         return $this;
-     }
- 
-     public function getFacebook(): ?string
-     {
-         return $this->facebook;
-     }
- 
-     public function setFacebook(?string $facebook): self
-     {
-         $this->facebook = $facebook;
- 
-         return $this;
-     }
- 
-     public function getInstagram(): ?string
-     {
-         return $this->instagram;
-     }
- 
-     public function setInstagram(?string $instagram): self
-     {
-         $this->instagram = $instagram;
- 
-         return $this;
-     }
- 
-     public function getTwitter(): ?string
-     {
-         return $this->twitter;
-     }
- 
-     public function setTwitter(?string $twitter): self
-     {
-         $this->twitter = $twitter;
- 
-         return $this;
-     }
- 
-     public function getLien(): ?string
-     {
-         return $this->lien;
-     }
- 
-     public function setLien(?string $lien): self
-     {
-         $this->lien = $lien;
- 
-         return $this;
-     }
- 
-     public function getImageProfil(): ?string
-     {
-         return $this->image_profil;
-     }
- 
-     public function setImageProfil(string $image_profil): self
-     {
-         $this->image_profil = $image_profil;
- 
-         return $this;
-     }
- 
-     public function getImageProfilAlt(): ?string
-     {
-         return $this->image_profil_alt;
-     }
- 
-     public function setImageProfilAlt(string $image_profil_alt): self
-     {
-         $this->image_profil_alt = $image_profil_alt;
- 
-         return $this;
-     }
- 
-     public function getImageBandeau(): ?string
-     {
-         return $this->image_bandeau;
-     }
- 
-     public function setImageBandeau(string $image_bandeau): self
-     {
-         $this->image_bandeau = $image_bandeau;
- 
-         return $this;
-     }
- 
-     public function getImageBandeauAlt(): ?string
-     {
-         return $this->image_bandeau_alt;
-     }
- 
-     public function setImageBandeauAlt(string $image_bandeau_alt): self
-     {
-         $this->image_bandeau_alt = $image_bandeau_alt;
- 
-         return $this;
-     }
- 
-     public function getCreatedAt(): ?\DateTimeImmutable
-     {
-         return $this->created_at;
-     }
- 
-     public function setCreatedAt(\DateTimeImmutable $created_at): self
-     {
-         $this->created_at = $created_at;
- 
-         return $this;
-     }
- 
-     public function getChocolaterie(): ?Chocolaterie
-     {
-         return $this->chocolaterie;
-     }
- 
-     public function setChocolaterie(?Chocolaterie $chocolaterie): self
-     {
-         $this->chocolaterie = $chocolaterie;
- 
-         return $this;
-     }
- 
-     /**
-      * @return Collection<int, Like>
-      */
-     public function getLikes(): Collection
-     {
-         return $this->likes;
-     }
- 
-     public function addLike(Like $like): self
-     {
-         if (!$this->likes->contains($like)) {
-             $this->likes->add($like);
-             $like->setUser($this);
-         }
- 
-         return $this;
-     }
- 
-     public function removeLike(Like $like): self
-     {
-         if ($this->likes->removeElement($like)) {
-             // set the owning side to null (unless already changed)
-             if ($like->getUser() === $this) {
-                 $like->setUser(null);
-             }
-         }
- 
-         return $this;
-     }
- 
-     /**
-      * @return Collection<int, Commentaire>
-      */
-     public function getCommentaires(): Collection
-     {
-         return $this->commentaires;
-     }
- 
-     public function addCommentaire(Commentaire $commentaire): self
-     {
-         if (!$this->commentaires->contains($commentaire)) {
-             $this->commentaires->add($commentaire);
-             $commentaire->setUser($this);
-         }
- 
-         return $this;
-     }
- 
-     public function removeCommentaire(Commentaire $commentaire): self
-     {
-         if ($this->commentaires->removeElement($commentaire)) {
-             // set the owning side to null (unless already changed)
-             if ($commentaire->getUser() === $this) {
-                 $commentaire->setUser(null);
-             }
-         }
- 
-         return $this;
-     }
- 
-     /**
-      * @return Collection<int, Post>
-      */
-     public function getPosts(): Collection
-     {
-         return $this->posts;
-     }
- 
-     public function addPost(Post $post): self
-     {
-         if (!$this->posts->contains($post)) {
-             $this->posts->add($post);
-             $post->setUser($this);
-         }
- 
-         return $this;
-     }
- 
-     public function removePost(Post $post): self
-     {
-         if ($this->posts->removeElement($post)) {
-             // set the owning side to null (unless already changed)
-             if ($post->getUser() === $this) {
-                 $post->setUser(null);
-             }
-         }
- 
-         return $this;
-     }
- }
-