src/Entity/User.php line 16

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. #[ORM\Table(name'`user`')]
  12. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  13. class User implements UserInterfacePasswordAuthenticatedUserInterface
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id null;
  19.     #[ORM\Column(length180uniquetrue)]
  20.     private ?string $email null;
  21.     #[ORM\Column]
  22.     private array $roles = [''];
  23.     //private array $roles = ['ROLE_USER']; Permet d'ajouter que des utilisateurs
  24.     /**
  25.      * @var string The hashed password
  26.      */
  27.     #[ORM\Column]
  28.     private ?string $password null;
  29.     #[ORM\Column(length255)]
  30.     private ?string $nom null;
  31.     #[ORM\Column(length255)]
  32.     private ?string $prenom null;
  33.     #[ORM\Column(length255)]
  34.     private ?string $poste null;
  35.     #[ORM\Column(length255nullabletrue)]
  36.     private ?string $description null;
  37.     #[ORM\Column(length255nullabletrue)]
  38.     private ?string $linkedin null;
  39.     #[ORM\Column(length255nullabletrue)]
  40.     private ?string $facebook null;
  41.     #[ORM\Column(length255nullabletrue)]
  42.     private ?string $instagram null;
  43.     #[ORM\Column(length255nullabletrue)]
  44.     private ?string $twitter null;
  45.     #[ORM\Column(length255nullabletrue)]
  46.     private ?string $lien null;
  47.     #[ORM\Column(length255)]
  48.     private ?string $image_profil null;
  49.     #[ORM\Column(length255)]
  50.     private ?string $image_profil_alt null;
  51.     #[ORM\Column(length255)]
  52.     private ?string $image_bandeau null;
  53.     #[ORM\Column(length255)]
  54.     private ?string $image_bandeau_alt null;
  55.     #[ORM\Column]
  56.     private ?\DateTimeImmutable $created_at null;
  57.     #[ORM\ManyToOne(inversedBy'users')]
  58.     #[ORM\JoinColumn(nullablefalse)]
  59.     private ?Chocolaterie $chocolaterie null;
  60.     #[ORM\OneToMany(mappedBy'user'targetEntityLike::class, orphanRemovaltrue)]
  61.     private Collection $likes;
  62.     #[ORM\OneToMany(mappedBy'user'targetEntityCommentaire::class, orphanRemovaltrue)]
  63.     private Collection $commentaires;
  64.     #[ORM\OneToMany(mappedBy'user'targetEntityPost::class, orphanRemovaltrue)]
  65.     private Collection $posts;
  66.     public function __construct()
  67.     {
  68.         $this->likes = new ArrayCollection();
  69.         $this->commentaires = new ArrayCollection();
  70.         $this->posts = new ArrayCollection();
  71.     }
  72.     public function getId(): ?int
  73.     {
  74.         return $this->id;
  75.     }
  76.     public function getEmail(): ?string
  77.     {
  78.         return $this->email;
  79.     }
  80.     public function setEmail(string $email): self
  81.     {
  82.         $this->email $email;
  83.         return $this;
  84.     }
  85.     /**
  86.      * A visual identifier that represents this user.
  87.      *
  88.      * @see UserInterface
  89.      */
  90.     public function getUserIdentifier(): string
  91.     {
  92.         return (string) $this->email;
  93.     }
  94.     /**
  95.      * @see UserInterface
  96.      */
  97.     public function getRoles(): array
  98.     {
  99.         $roles $this->roles;
  100.         // guarantee every user at least has ROLE_USER
  101.         $roles[] = 'ROLE_USER';
  102.         return array_unique($roles);
  103.     }
  104.     public function setRoles(array $roles): self
  105.     {
  106.         $this->roles $roles;
  107.         return $this;
  108.     }
  109.     /**
  110.      * @see PasswordAuthenticatedUserInterface
  111.      */
  112.     public function getPassword(): string
  113.     {
  114.         return $this->password;
  115.     }
  116.     public function setPassword(string $password): self
  117.     {
  118.         $this->password $password;
  119.         return $this;
  120.     }
  121.     /**
  122.      * @see UserInterface
  123.      */
  124.     public function eraseCredentials()
  125.     {
  126.         // If you store any temporary, sensitive data on the user, clear it here
  127.         // $this->plainPassword = null;
  128.     }
  129.     public function getNom(): ?string
  130.     {
  131.         return $this->nom;
  132.     }
  133.     public function setNom(string $nom): self
  134.     {
  135.         $this->nom $nom;
  136.         return $this;
  137.     }
  138.     public function getPrenom(): ?string
  139.     {
  140.         return $this->prenom;
  141.     }
  142.     public function setPrenom(string $prenom): self
  143.     {
  144.         $this->prenom $prenom;
  145.         return $this;
  146.     }
  147.     public function getPoste(): ?string
  148.     {
  149.         return $this->poste;
  150.     }
  151.     public function setPoste(string $poste): self
  152.     {
  153.         $this->poste $poste;
  154.         return $this;
  155.     }
  156.     public function getDescription(): ?string
  157.     {
  158.         return $this->description;
  159.     }
  160.     public function setDescription(?string $description): self
  161.     {
  162.         $this->description $description;
  163.         return $this;
  164.     }
  165.     public function getLinkedin(): ?string
  166.     {
  167.         return $this->linkedin;
  168.     }
  169.     public function setLinkedin(?string $linkedin): self
  170.     {
  171.         $this->linkedin $linkedin;
  172.         return $this;
  173.     }
  174.     public function getFacebook(): ?string
  175.     {
  176.         return $this->facebook;
  177.     }
  178.     public function setFacebook(?string $facebook): self
  179.     {
  180.         $this->facebook $facebook;
  181.         return $this;
  182.     }
  183.     public function getInstagram(): ?string
  184.     {
  185.         return $this->instagram;
  186.     }
  187.     public function setInstagram(?string $instagram): self
  188.     {
  189.         $this->instagram $instagram;
  190.         return $this;
  191.     }
  192.     public function getTwitter(): ?string
  193.     {
  194.         return $this->twitter;
  195.     }
  196.     public function setTwitter(?string $twitter): self
  197.     {
  198.         $this->twitter $twitter;
  199.         return $this;
  200.     }
  201.     public function getLien(): ?string
  202.     {
  203.         return $this->lien;
  204.     }
  205.     public function setLien(?string $lien): self
  206.     {
  207.         $this->lien $lien;
  208.         return $this;
  209.     }
  210.     public function getImageProfil(): ?string
  211.     {
  212.         return $this->image_profil;
  213.     }
  214.     public function setImageProfil(string $image_profil): self
  215.     {
  216.         $this->image_profil $image_profil;
  217.         return $this;
  218.     }
  219.     public function getImageProfilAlt(): ?string
  220.     {
  221.         return $this->image_profil_alt;
  222.     }
  223.     public function setImageProfilAlt(string $image_profil_alt): self
  224.     {
  225.         $this->image_profil_alt $image_profil_alt;
  226.         return $this;
  227.     }
  228.     public function getImageBandeau(): ?string
  229.     {
  230.         return $this->image_bandeau;
  231.     }
  232.     public function setImageBandeau(string $image_bandeau): self
  233.     {
  234.         $this->image_bandeau $image_bandeau;
  235.         return $this;
  236.     }
  237.     public function getImageBandeauAlt(): ?string
  238.     {
  239.         return $this->image_bandeau_alt;
  240.     }
  241.     public function setImageBandeauAlt(string $image_bandeau_alt): self
  242.     {
  243.         $this->image_bandeau_alt $image_bandeau_alt;
  244.         return $this;
  245.     }
  246.     public function getCreatedAt(): ?\DateTimeImmutable
  247.     {
  248.         return $this->created_at;
  249.     }
  250.     public function setCreatedAt(\DateTimeImmutable $created_at): self
  251.     {
  252.         $this->created_at $created_at;
  253.         return $this;
  254.     }
  255.     public function getChocolaterie(): ?Chocolaterie
  256.     {
  257.         return $this->chocolaterie;
  258.     }
  259.     public function setChocolaterie(?Chocolaterie $chocolaterie): self
  260.     {
  261.         $this->chocolaterie $chocolaterie;
  262.         return $this;
  263.     }
  264.     /**
  265.      * @return Collection<int, Like>
  266.      */
  267.     public function getLikes(): Collection
  268.     {
  269.         return $this->likes;
  270.     }
  271.     public function addLike(Like $like): self
  272.     {
  273.         if (!$this->likes->contains($like)) {
  274.             $this->likes->add($like);
  275.             $like->setUser($this);
  276.         }
  277.         return $this;
  278.     }
  279.     public function removeLike(Like $like): self
  280.     {
  281.         if ($this->likes->removeElement($like)) {
  282.             // set the owning side to null (unless already changed)
  283.             if ($like->getUser() === $this) {
  284.                 $like->setUser(null);
  285.             }
  286.         }
  287.         return $this;
  288.     }
  289.     /**
  290.      * @return Collection<int, Commentaire>
  291.      */
  292.     public function getCommentaires(): Collection
  293.     {
  294.         return $this->commentaires;
  295.     }
  296.     public function addCommentaire(Commentaire $commentaire): self
  297.     {
  298.         if (!$this->commentaires->contains($commentaire)) {
  299.             $this->commentaires->add($commentaire);
  300.             $commentaire->setUser($this);
  301.         }
  302.         return $this;
  303.     }
  304.     public function removeCommentaire(Commentaire $commentaire): self
  305.     {
  306.         if ($this->commentaires->removeElement($commentaire)) {
  307.             // set the owning side to null (unless already changed)
  308.             if ($commentaire->getUser() === $this) {
  309.                 $commentaire->setUser(null);
  310.             }
  311.         }
  312.         return $this;
  313.     }
  314.     /**
  315.      * @return Collection<int, Post>
  316.      */
  317.     public function getPosts(): Collection
  318.     {
  319.         return $this->posts;
  320.     }
  321.     public function addPost(Post $post): self
  322.     {
  323.         if (!$this->posts->contains($post)) {
  324.             $this->posts->add($post);
  325.             $post->setUser($this);
  326.         }
  327.         return $this;
  328.     }
  329.     public function removePost(Post $post): self
  330.     {
  331.         if ($this->posts->removeElement($post)) {
  332.             // set the owning side to null (unless already changed)
  333.             if ($post->getUser() === $this) {
  334.                 $post->setUser(null);
  335.             }
  336.         }
  337.         return $this;
  338.     }
  339. }