src/Entity/User.php line 17
<?phpnamespace 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\UserInterface;use Symfony\Component\Validator\Constraints as Assert;use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;use Symfony\Component\Validator\Constraints\Json;#[ORM\Entity(repositoryClass: UserRepository::class)]#[UniqueEntity(fields: ['user_email'], message: 'Il existe déjà un compte avec cette adresse email.')]class User implements PasswordAuthenticatedUserInterface, UserInterface{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 255)]#[Assert\NotBlank(message: 'Veuillez renseigner votre prénom.')]#[Assert\Type(type: 'string', message: 'Le prénom doit être une chaîne de caractères.')]private ?string $user_name = null;#[ORM\Column(length: 255)]#[Assert\NotBlank(message: 'Veuillez renseigner votre nom.')]#[Assert\Type(type: 'string', message: 'Le nom doit être une chaîne de caractères.')]private ?string $user_surname = null;#[ORM\Column(length: 255, unique: true)]#[Assert\NotBlank(message: 'Veuillez renseigner une adresse email.')]#[Assert\Email(message: 'Veuillez renseigner une adresse email valide.')]private ?string $user_email = null;#[ORM\Column(length: 255)]#[Assert\NotBlank(message: 'Veuillez renseigner un mot de passe.')]#[Assert\Length(min: 8,max: 32,minMessage: 'Votre mot de passe doit contenir au moins {{ limit }} caractères.',maxMessage: 'Votre mot de passe ne peut pas faire plus de {{ limit }} caractères.')]#[Assert\Regex(pattern: '/^(?=.*[0-9]).*$/',message: "Votre mot de passe doit contenir au moins un chiffre.")]#[Assert\Regex(pattern: '/^(?=.*[A-Z]).*$/',message: "Votre mot de passe doit contenir au moins une lettre majuscule.")]private ?string $user_password = null;#[ORM\OneToMany(mappedBy: 'order_user', targetEntity: Order::class)]private Collection $orders;#[ORM\Column]private array $user_roles = ['ROLE_USER'];private ?string $confirm_password = null;private ?string $confirm_email = null;public function __construct(){$this->orders = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getUserName(): ?string{return $this->user_name;}public function setUserName(string $user_name): self{$this->user_name = $user_name;return $this;}public function getUserSurname(): ?string{return $this->user_surname;}public function setUserSurname(string $user_surname): self{$this->user_surname = $user_surname;return $this;}public function getUserEmail(): ?string{return $this->user_email;}public function setUserEmail(string $user_email): self{$this->user_email = $user_email;return $this;}/*** @return string|null*/public function getUserPassword(): ?string{return $this->user_password;}/*** @param string|null $user_password*/public function setUserPassword(?string $user_password): void{$this->user_password = $user_password;}public function getPassword(): ?string{return $this->user_password;}public function setPassword(string $user_password): self{$this->user_password = $user_password;return $this;}/*** @return Collection<int, Order>*/public function getOrders(): Collection{return $this->orders;}public function addOrder(Order $order): self{if (!$this->orders->contains($order)) {$this->orders->add($order);$order->setOrderUser($this);}return $this;}public function removeOrder(Order $order): self{if ($this->orders->removeElement($order)) {// set the owning side to null (unless already changed)if ($order->getOrderUser() === $this) {$order->setOrderUser(null);}}return $this;}public function getConfirmPassword(): ?string{return $this->confirm_password;}public function setConfirmPassword(string $confirm_password): self{$this->confirm_password = $confirm_password;return $this;}public function getConfirmEmail(): ?string{return $this->confirm_email;}public function setConfirmEmail(string $confirm_email): self{$this->confirm_email = $confirm_email;return $this;}public function getRoles(): array{$roles = $this->user_roles;// guarantee every user at least has ROLE_USER$roles[] = 'ROLE_USER';return array_unique($roles);}public function setRoles(array $roles): self{$this->user_roles = $roles;return $this;}public function eraseCredentials(){// TODO: Implement eraseCredentials() method.}public function getUserIdentifier(): string{return (string) $this->user_email;}public function getUserRoles(): array{return $this->user_roles;}public function setUserRoles(array $user_roles): self{$this->user_roles = $user_roles;return $this;}public function __toString(): string{return $this->user_name . ' ' . $this->user_surname;}}