src/Entity/User.php line 43
<?phpnamespace App\Entity;use App\Repository\UserRepository;use DateTime;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;use Symfony\Component\Security\Core\User\UserInterface;use App\Model\Constant\UserRole;use Symfony\Component\Serializer\Annotation\Groups;use Symfony\Component\Validator\Constraints as Assert;use App\Security\Model\BelongUser;use ApiPlatform\Metadata\ApiResource;use ApiPlatform\Metadata\GetCollection;use ApiPlatform\Metadata\Get;use ApiPlatform\Metadata\Put;use App\Controller\Api\User\UserController;use App\Validator\Constraints as AssertApp;use App\Entity\MediaObject;use Vich\UploaderBundle\Mapping\Annotation as Vich;#[ORM\Entity(repositoryClass: UserRepository::class)]#[ORM\Table(name: '`user`')]#[Vich\Uploadable]#[ApiResource(operations: [new GetCollection(),new Get(normalizationContext: ['groups' => ['user_get', 'user_getc', 'user_get_me']]),new Put(routeName: 'app_api_users',controller: UserController::class,normalizationContext: ['groups' => ['user_put', 'app_api_users']],denormalizationContext: ['groups' => ['user_put']])])]class User implements UserInterface, PasswordAuthenticatedUserInterface, BelongUser{final public const ROLE_USER = 'ROLE_USER';final public const ROLE_ADMIN = 'ROLE_ADMIN';#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]#[Groups(['user_get', 'user_getc','user_get_me','token_get_login',])]private ?int $id = null;#[ORM\Column(length: 180, unique: true)]#[Groups(['user_get', 'user_getc', 'user_post','user_get_me', 'user_put','token_get_login',])]#[Assert\Length(max: 255, groups: ['user_post'])]#[Assert\NotBlank(groups: ['user_post'])]#[Assert\Email(groups: ['user_post'])]private ?string $email = null;// #[ORM\Column(type: 'array_pipe')]#[Groups(['user_get', 'user_getc','user_get_me','token_get_login'])]#[Assert\Choice(callback: [UserRole::class, "getValues"], multiple: true)]#[ORM\Column(type: Types::JSON)]private array $roles = [];/*** @var string The hashed password*/#[ORM\Column]#[Groups(['user_patch_password', 'user_patch_resetPasswordConfirm', 'user_post'])]#[Assert\NotBlank(groups: ['user_patch_password', 'user_patch_resetPasswordConfirm'])]private ?string $password = null;#[ORM\Column(length: 255)]#[Groups(['user_get', 'user_getc', 'user_post', 'user_put','user_get_me','token_get_login'])]#[Assert\Length(max: 45, groups: ['user_post', 'user_put'])]#[Assert\NotBlank(groups: ['user_post', 'user_put'])]private ?string $fullName = null;#[ORM\Column(length: 45, nullable: true)]#[Groups(['user_get', 'user_getc', 'user_post', 'user_put','user_get_me','token_get_login'])]private ?string $phone = null;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]#[Groups(['user_get', 'user_getc', 'user_post', 'user_put','user_get_me','token_get_login'])]#[Assert\NotBlank(groups: ['user_post', 'user_put'])]private ?\DateTime $dateOfBirth = null;#[ORM\Column(length: 2000, nullable: true)]#[Groups(['user_get', 'user_getc', 'user_post','user_get_me'])]#[Assert\NotBlank(groups: ['user_post'])]private ?string $walletNumber = null;#[ORM\Column(type: Types::DATETIME_MUTABLE)]private ?\DateTime $createdAt = null;#[ORM\OneToMany(mappedBy: 'user', targetEntity: Order::class)]#[Groups(['user_get', 'user_getc','user_get_me', 'token_get_login'])]private Collection $orders;#[ORM\Column(length: 255, nullable: true)]#[Groups(['user_get', 'user_getc', 'user_post','user_get_me', 'user_put', 'token_get_login'])]private ?string $adresse = null;#[Groups(['user_get_me',])]private ?Token $currentToken;/*** @var ArrayCollection<Token>*/#[ORM\OneToMany(targetEntity: Token::class, mappedBy: 'user', cascade: ['remove'])]private Collection $tokens;/*** @var ArrayCollection<Token>*/#[ORM\OneToMany(targetEntity: RefreshToken::class, mappedBy: 'user', cascade: ['remove'])]private Collection $refreshTokens;// #[ORM\Column(length: 10, type: 'gender_enum')]#[ORM\Column(length: 10, nullable: true)]#[Groups(['user_get', 'user_getc', 'user_put','user_get_me', 'token_get_login'])]private ?string $gender = null;#[Groups(['user_get', 'user_getc', 'user_get_me', 'token_get_login'])]#[ORM\OneToMany(mappedBy: 'user', targetEntity: Card::class)]private Collection $cards;#[ORM\Column(length: 255, nullable: true)]#[Groups(['user_get', 'user_getc', 'user_put','user_get_me', 'token_get_login'])]private ?string $country = null;#[ORM\Column(length: 255, nullable: true)]#[Groups(['user_get', 'user_getc', 'user_post', 'user_put', 'token_get_login'])]private ?string $nationality = null;#[Groups(['user_get', 'user_getc', 'user_post', 'user_put','user_get_me','token_get_login'])]#[ORM\OneToMany(mappedBy: 'user', targetEntity: MediaObject::class)]private Collection $file;#[ORM\Column]#[Groups(['user_get', 'user_getc', 'user_post', 'user_put', 'token_get_login'])]private ?bool $isExist = false;#[Groups(['user_get', 'user_getc', 'user_post', 'user_put','user_get_me','token_get_login'])]#[ORM\Column(length: 255, nullable: true)]private ?string $signatureImage = null;#[ORM\Column(length: 255, nullable: true)]#[Groups(['user_get', 'user_getc', 'user_put','user_get_me', 'token_get_login'])]private ?string $city = null;#[ORM\OneToOne(inversedBy: 'user', cascade: ['persist', 'remove'])]#[Groups(['user_get', 'user_getc', 'user_put','user_get_me', 'token_get_login'])]private ?Company $company = null;public function __construct(){$this->createdAt = new DateTime();$this->orders = new ArrayCollection();$this->tokens = new ArrayCollection();$this->refreshTokens = new ArrayCollection();$this->setRoles([UserRole::ROLE_USER]);$this->cards = new ArrayCollection();$this->file = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getEmail(): ?string{return $this->email;}public function setEmail(string $email): static{$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[] = self::ROLE_USER;return array_unique($roles);}public function setRoles(array $roles): static{$this->roles = $roles;return $this;}/*** @see PasswordAuthenticatedUserInterface*/public function getPassword(): string{return $this->password;}public function setPassword(string $password): static{$this->password = $password;return $this;}/*** @see UserInterface*/public function eraseCredentials(): void{// If you store any temporary, sensitive data on the user, clear it here// $this->plainPassword = null;}public function getFullName(): ?string{return $this->fullName;}public function setFullName(string $fullName): static{$this->fullName = $fullName;return $this;}public function getPhone(): ?string{return $this->phone;}public function setPhone(?string $phone): static{$this->phone = $phone;return $this;}public function getDateOfBirth(): ?\DateTime{return $this->dateOfBirth;}public function setDateOfBirth(?\DateTime $dateOfBirth): static{$this->dateOfBirth = $dateOfBirth;return $this;}public function getWalletNumber(): ?string{return $this->walletNumber;}public function setWalletNumber(?string $walletNumber): static{$this->walletNumber = $walletNumber;return $this;}public function getCreatedAt(): ?\DateTime{return $this->createdAt;}public function setCreatedAt(\DateTime $createdAt): static{$this->createdAt = $createdAt;return $this;}/*** @return Collection<int, Order>*/public function getOrders(): Collection{return $this->orders;}public function addOrder(Order $order): static{if (!$this->orders->contains($order)) {$this->orders->add($order);$order->setUser($this);}return $this;}public function removeOrder(Order $order): static{if ($this->orders->removeElement($order)) {// set the owning side to null (unless already changed)if ($order->getUser() === $this) {$order->setUser(null);}}return $this;}public function getAdresse(): ?string{return $this->adresse;}public function setAdresse(?string $adresse): static{$this->adresse = $adresse;return $this;}public function getGender(): ?string{return $this->gender;}public function setGender(string $gender): static{$this->gender = $gender;return $this;}/*** @return Collection<Token>*/public function getTokens(){return $this->tokens;}/*** @return Collection<Token>*/public function getRefreshTokens(){return $this->refreshTokens;}public function getCurrentToken(): ?Token{return $this->currentToken;}public function setCurrentToken(Token $currentToken): self{$this->currentToken = $currentToken;return $this;}/*** @param $data* @param string[] $groups*/public function unserializeTransform($data, array $groups): void{if (in_array('user_post', $groups)) {if (!$this->getRoles()) {$this->addRole(UserRole::ROLE_USER);}$roles = $this->getRoles();$this->setRoles([]);foreach ($roles as $role) {if (in_array($role, UserRole::getValues())) {$this->addRole($role);}}}}public function addRole(string $role): self{$roles = $this->getRoles();if (!in_array($role, $roles)) {$roles[] = $role;$this->setRoles($roles);}return $this;}public function removeRole(string $role): self{$roles = $this->getRoles();if (($key = array_search($role, $roles)) !== false) {unset($roles[$key]);$this->setRoles($roles);}return $this;}public function hasRole(string $role): bool{return in_array($role, $this->getRoles());}public function addToken(Token $token): self{if (!$this->tokens->contains($token)) {$this->tokens->add($token);}return $this;}public function addRefreshToken(RefreshToken $refreshToken): self{if (!$this->refreshTokens->contains($refreshToken)) {$this->refreshTokens->add($refreshToken);}return $this;}public function getUser(): User{return $this;}/*** @return Collection<int, Card>*/public function getCards(): Collection{return $this->cards;}public function addCard(Card $card): static{if (!$this->cards->contains($card)) {$this->cards->add($card);$card->setUser($this);}return $this;}public function removeCard(Card $card): static{if ($this->cards->removeElement($card)) {// set the owning side to null (unless already changed)if ($card->getUser() === $this) {$card->setUser(null);}}return $this;}public function getCountry(): ?string{return $this->country;}public function setCountry(?string $country): static{$this->country = $country;return $this;}public function getNationality(): ?string{return $this->nationality;}public function setNationality(?string $nationality): static{$this->nationality = $nationality;return $this;}/*** @return Collection<int, MediaObject>*/public function getFile(): Collection{return $this->file;}public function addFile(MediaObject $file): static{if (!$this->file->contains($file)) {$this->file->add($file);$file->setUser($this);}return $this;}public function removeFile(MediaObject $file): static{if ($this->file->removeElement($file)) {// set the owning side to null (unless already changed)if ($file->getUser() === $this) {$file->setUser(null);}}return $this;}public function getIsExist(): ?bool{return $this->isExist;}public function setIsExist(bool $isExist): static{$this->isExist = $isExist;return $this;}public function getSignatureImage(): ?string{return $this->signatureImage;}public function setSignatureImage(?string $signatureImage): static{$this->signatureImage = $signatureImage;return $this;}public function getCity(): ?string{return $this->city;}public function setCity(?string $city): static{$this->city = $city;return $this;}public function getCompany(): ?Company{return $this->company;}public function setCompany(?Company $company): static{$this->company = $company;return $this;}}