src/Entity/User.php line 36
<?phpnamespace App\Entity;use ApiPlatform\Metadata\ApiResource;use ApiPlatform\Metadata\Get;use ApiPlatform\Metadata\GetCollection;use ApiPlatform\Metadata\Post;use ApiPlatform\Metadata\Put;use ApiPlatform\Metadata\Patch;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;use Symfony\Component\Serializer\Annotation\Groups;#[ORM\Entity(repositoryClass: UserRepository::class)]#[ApiResource(normalizationContext: ['groups' => ['read:user']],denormalizationContext: ['groups' => ['write:user']],operations: [new Get(),new GetCollection(),new Post(),new Put(),new Patch(),],paginationEnabled: true,paginationItemsPerPage: 30)]#[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]#[Groups(['read:user','write:user'])]private ?int $id = null;#[Groups(['read:user','write:user'])]#[ORM\Column(length: 180, unique: true)]private ?string $email = null;#[ORM\Column]#[Groups(['read:user','write:user'])]private array $roles = [];/*** @var string The hashed password*/#[ORM\Column]#[Groups(['write:user'])] // Ne jamais exposer le mot de passe en lectureprivate ?string $password = null;#[ORM\Column]#[Groups(['read:user','write:user'])]private ?bool $isdelete = false;#[ORM\OneToMany(mappedBy: 'user', targetEntity: Personne::class)]#[Groups(['read:user','read:personne'])]private Collection $personnes;#[ORM\Column]#[Groups(['read:user','read:personne','write:user',])]private ?bool $oneConnexion =false;#[ORM\OneToMany(mappedBy: 'client', targetEntity: Acheter::class)]private Collection $acheters;#[ORM\Column(length: 255, nullable: true)]private ?string $log = null;public function __construct(){$this->personnes = new ArrayCollection();$this->acheters = 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 isIsdelete(): ?bool{return $this->isdelete;}public function setIsdelete(bool $isdelete): self{$this->isdelete = $isdelete;return $this;}/*** @return Collection<int, Personne>*/public function getPersonnes(): Collection{return $this->personnes;}public function addPersonne(Personne $personne): self{if (!$this->personnes->contains($personne)) {$this->personnes->add($personne);$personne->setUser($this);}return $this;}public function removePersonne(Personne $personne): self{if ($this->personnes->removeElement($personne)) {// set the owning side to null (unless already changed)if ($personne->getUser() === $this) {$personne->setUser(null);}}return $this;}public function isOneConnexion(): ?bool{return $this->oneConnexion;}public function setOneConnexion(bool $oneConnexion): self{$this->oneConnexion = $oneConnexion;return $this;}/*** @return Collection<int, Acheter>*/public function getAcheters(): Collection{return $this->acheters;}public function addAcheter(Acheter $acheter): self{if (!$this->acheters->contains($acheter)) {$this->acheters->add($acheter);$acheter->setClient($this);}return $this;}public function removeAcheter(Acheter $acheter): self{if ($this->acheters->removeElement($acheter)) {// set the owning side to null (unless already changed)if ($acheter->getClient() === $this) {$acheter->setClient(null);}}return $this;}public function getLog(): ?string{return $this->log;}public function setLog(?string $log): static{$this->log = $log;return $this;}public function __toString(): string{$personne = $this->getPersonnes()->first();if ($personne) {return sprintf('%s %s', $personne->getNom(), $personne->getPrenom());}return $this->email ?? 'User #' . $this->id;}}