src/Entity/User.php line 46

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Controller\ApiUserController;
  5. use App\Repository\UserRepository;
  6. use App\Entity\GroupMatchSchedule;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\DBAL\Types\Types;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  12. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  13. use Symfony\Component\Security\Core\User\UserInterface;
  14. use Symfony\Component\Serializer\Annotation\Groups;
  15. use Symfony\Component\Validator\Constraints as Assert;
  16. #[ApiResource(
  17.     normalizationContext: [
  18.         'groups' => ['read:user:collection']
  19.     ],
  20.     denormalizationContext: [
  21.         'groups' => ['write:user:admin']
  22.     ],
  23.     collectionOperations: [
  24.         'get',
  25.         'post' => [
  26.             'security' => "is_granted('ROLE_ADMIN')",
  27.             'security_message' => 'Seul un administrateur peut créer un utilisateur via l’API.',
  28.         ],
  29.         'current_user_infos' => [
  30.             'method' => 'GET',
  31.             'path' => '/users/me',
  32.             'controller' => ApiUserController::class,
  33.         ],
  34.     ],
  35.     itemOperations: [
  36.         'get',
  37.     ]
  38. )]
  39. #[ORM\Entity(repositoryClassUserRepository::class)]
  40. #[ORM\Table(name'`user`')]
  41. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  42. #[UniqueEntity(fields: ['username'], message'There is already an account with this username')]
  43. class User implements UserInterfacePasswordAuthenticatedUserInterface
  44. {
  45.     private const AVAILABILITY_SLOTS = ['now''tonight''weekend'];
  46.     #[ORM\Id]
  47.     #[ORM\GeneratedValue]
  48.     #[ORM\Column(type'integer')]
  49.     #[Groups([
  50.         'read:user:collection',
  51.         'read:message:collection',
  52.         'read:relation:collection',
  53.         'read:notification:collection',
  54.         'read:post:collection',
  55.         'read:placeComment:collection',
  56.         'read:groupUser:collection',
  57.         'read:event:collection',
  58.         'read:reservation:collection',
  59.         'read:conversation:collection',
  60.     ])]
  61.     private $id;
  62.     #[Groups([
  63.         'read:user:collection',
  64.         'read:message:collection',
  65.         'read:post:collection',
  66.         'read:placeComment:collection',
  67.         'read:relation:collection',
  68.         'read:notification:collection',
  69.         'read:groupUser:collection',
  70.         'read:event:collection',
  71.         'read:reservation:collection',
  72.         'read:conversation:collection',
  73.         'write:user:admin',
  74.     ])]
  75.     #[Assert\Length(min10max50)]
  76.     #[ORM\Column(type'string'length180uniquetrue)]
  77.     private $email;
  78.     #[Groups([
  79.         'read:user:collection',
  80.         'read:post:collection',
  81.         'read:message:collection',
  82.         'read:relation:collection',
  83.         'read:notification:collection',
  84.         'read:event:collection',
  85.         'read:reservation:collection',
  86.     ])]
  87.     #[ORM\Column(type'string'length500nullabletrue)]
  88.     private $image;
  89.     #[Groups([
  90.         'read:user:collection',
  91.         'read:post:collection',
  92.         'read:message:collection',
  93.         'read:relation:collection',
  94.         'read:notification:collection',
  95.         'read:event:collection',
  96.         'read:reservation:collection',
  97.     ])]
  98.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  99.     private ?string $backgroundImage null;
  100.     #[Groups([
  101.         'read:user:collection',
  102.         'read:message:collection',
  103.         'read:post:collection',
  104.         'read:placeComment:collection',
  105.         'read:relation:collection',
  106.         'read:notification:collection',
  107.         'read:groupUser:collection',
  108.         'read:event:collection',
  109.         'read:reservation:collection',
  110.         'write:user:admin',
  111.     ])]
  112.     #[ORM\Column(type'string'length50)]
  113.     private $username;
  114.     #[ORM\Column(type'json')]
  115.     private $roles = [];
  116.     #[Assert\Length(min6max50)]
  117.     #[ORM\Column(type'string')]
  118.     #[Groups(['write:user:admin'])]
  119.     private $password;
  120.     #[ORM\Column(type'datetime_immutable'nullabletrue)]
  121.     private ?\DateTimeImmutable $createdAt null;
  122.     #[Groups([
  123.         'read:user:collection',
  124.         'read:message:collection',
  125.         'read:relation:collection',
  126.     ])]
  127.     #[ORM\Column(type'string'length500nullabletrue)]
  128.     private ?string $bioShort null;
  129.     #[ORM\OneToMany(mappedBy'sourceUser'targetEntityMessage::class)]
  130.     private $sourceMessages;
  131.     #[ORM\ManyToMany(targetEntityGroupUser::class, mappedBy'concernedUsers'cascade: ['persist''remove'])]
  132.     private $groupUsers;
  133.     #[ORM\OneToOne(mappedBy'user'targetEntityFlux::class, cascade: ['persist''remove'])]
  134.     private $flux;
  135.     #[ORM\OneToMany(mappedBy'initialUser'targetEntityActivity::class)]
  136.     private $sourceAtivities;
  137.     #[ORM\ManyToMany(targetEntityActivity::class)]
  138.     private $targetActivities;
  139.     #[ORM\OneToMany(mappedBy'sourceUser'targetEntityNotification::class)]
  140.     private $sourceNotifications;
  141.     #[ORM\OneToMany(mappedBy'targetUser'targetEntityNotification::class)]
  142.     private $targetNotifications;
  143.     #[ORM\Column(type'string'length500nullabletrue)]
  144.     private $authToken;
  145.     #[ORM\OneToOne(targetEntityGroupUser::class, cascade: ['persist''remove'])]
  146.     private $relationGroupUser;
  147.     #[ORM\Column(type'text'nullabletrue)]
  148.     private $payData;
  149.     #[ORM\Column(nullabletrue)]
  150.     private ?bool $isActif null;
  151.     #[ORM\Column(type'json'nullabletrue)]
  152.     private ?array $availabilitySlots = [];
  153.     #[ORM\Column(type'datetime_immutable'nullabletrue)]
  154.     private ?\DateTimeImmutable $availabilityUpdatedAt null;
  155.     #[ORM\OneToMany(mappedBy'sourceUser'targetEntityPayment::class)]
  156.     private Collection $payments;
  157.     #[ORM\Column(nullabletrue)]
  158.     private ?bool $isConfirmed null;
  159.     #[Groups([
  160.         'read:user:collection',
  161.         'read:message:collection',
  162.         'read:relation:collection',
  163.         'read:notification:collection',
  164.         'read:conversation:collection',
  165.     ])]
  166.     #[ORM\Column(type'json'nullabletrue)]
  167.     private ?array $requirements = [];
  168.     #[Groups([
  169.         'read:user:collection',
  170.         'read:message:collection',
  171.         'read:relation:collection',
  172.         'read:notification:collection',
  173.         'read:conversation:collection',
  174.     ])]
  175.     #[ORM\Column(type'boolean'options: ['default' => false])]
  176.     private bool $isPremium false;
  177.     #[ORM\Column(nullabletrue)]
  178.     private ?array $position null;
  179.     #[ORM\Column(type'boolean'options: ['default' => false])]
  180.     private bool $locationOptIn false;
  181.     #[ORM\Column(type'datetime_immutable'nullabletrue)]
  182.     private ?\DateTimeImmutable $locationUpdatedAt null;
  183.     #[ORM\OneToMany(mappedBy'user'targetEntityReservation::class, orphanRemovaltrue)]
  184.     private Collection $reservations;
  185.     #[ORM\OneToOne(mappedBy'owner'cascade: ['persist''remove'])]
  186.     private ?Account $account null;
  187.     #[ORM\OneToMany(mappedBy'organizer'targetEntityGroupMatchSchedule::class)]
  188.     private Collection $groupMatchSchedules;
  189.     #[ORM\Column(type'float'nullabletrue)]
  190.     private ?float $reliabilityScore null;
  191.     #[ORM\Column(type'boolean'options: ['default' => false])]
  192.     private bool $ageVerified false;
  193.     #[ORM\Column(type'boolean'options: ['default' => false])]
  194.     private bool $identityVerified false;
  195.     #[ORM\Column(type'boolean'options: ['default' => false])]
  196.     private bool $incomeVerified false;
  197.     #[ORM\Column(type'boolean'options: ['default' => false])]
  198.     private bool $mfaEnabled false;
  199.     #[ORM\Column(type'string'length30nullabletrue)]
  200.     private ?string $mfaMethod null;
  201.     #[ORM\Column(type'datetime_immutable'nullabletrue)]
  202.     private ?\DateTimeImmutable $mfaVerifiedAt null;
  203.     public function __construct()
  204.     {
  205.         $this->roles = ['ROLE_USER'];
  206.         $this->sourceMessages = new ArrayCollection();
  207.         $this->groupUsers = new ArrayCollection();
  208.         $this->sourceAtivities = new ArrayCollection();
  209.         $this->targetActivities = new ArrayCollection();
  210.         $this->sourceNotifications = new ArrayCollection();
  211.         $this->targetNotifications = new ArrayCollection();
  212.         $this->authToken hash_hmac('sha512'random_bytes(150), random_bytes(150), false);
  213.         $this->payments = new ArrayCollection();
  214.         $this->reservations = new ArrayCollection();
  215.         $this->createdAt = new \DateTimeImmutable();
  216.         $this->requirements = [];
  217.         $this->isPremium false;
  218.         $this->groupMatchSchedules = new ArrayCollection();
  219.         $this->locationOptIn false;
  220.         $this->mfaEnabled false;
  221.     }
  222.     public function getReliabilityScore(): ?float
  223.     {
  224.         return $this->reliabilityScore;
  225.     }
  226.     public function setReliabilityScore(?float $reliabilityScore): self
  227.     {
  228.         $this->reliabilityScore $reliabilityScore !== null max(0min(100$reliabilityScore)) : null;
  229.         return $this;
  230.     }
  231.     public function isAgeVerified(): bool
  232.     {
  233.         return $this->ageVerified;
  234.     }
  235.     public function setAgeVerified(bool $ageVerified): self
  236.     {
  237.         $this->ageVerified $ageVerified;
  238.         return $this;
  239.     }
  240.     public function isIdentityVerified(): bool
  241.     {
  242.         return $this->identityVerified;
  243.     }
  244.     public function setIdentityVerified(bool $identityVerified): self
  245.     {
  246.         $this->identityVerified $identityVerified;
  247.         return $this;
  248.     }
  249.     public function isIncomeVerified(): bool
  250.     {
  251.         return $this->incomeVerified;
  252.     }
  253.     public function setIncomeVerified(bool $incomeVerified): self
  254.     {
  255.         $this->incomeVerified $incomeVerified;
  256.         return $this;
  257.     }
  258.     public function isMfaEnabled(): bool
  259.     {
  260.         return $this->mfaEnabled;
  261.     }
  262.     public function setMfaEnabled(bool $mfaEnabled): self
  263.     {
  264.         $this->mfaEnabled $mfaEnabled;
  265.         return $this;
  266.     }
  267.     public function getMfaMethod(): ?string
  268.     {
  269.         return $this->mfaMethod;
  270.     }
  271.     public function setMfaMethod(?string $mfaMethod): self
  272.     {
  273.         $this->mfaMethod $mfaMethod;
  274.         return $this;
  275.     }
  276.     public function getMfaVerifiedAt(): ?\DateTimeImmutable
  277.     {
  278.         return $this->mfaVerifiedAt;
  279.     }
  280.     public function setMfaVerifiedAt(?\DateTimeImmutable $mfaVerifiedAt): self
  281.     {
  282.         $this->mfaVerifiedAt $mfaVerifiedAt;
  283.         return $this;
  284.     }
  285.     public function getId(): ?int
  286.     {
  287.         return $this->id;
  288.     }
  289.     public function getEmail(): ?string
  290.     {
  291.         return $this->email;
  292.     }
  293.     public function setEmail(string $email): self
  294.     {
  295.         $this->email $email;
  296.         return $this;
  297.     }
  298.     /**
  299.      * @return Collection<int, GroupMatchSchedule>
  300.      */
  301.     public function getGroupMatchSchedules(): Collection
  302.     {
  303.         return $this->groupMatchSchedules;
  304.     }
  305.     public function addGroupMatchSchedule(GroupMatchSchedule $schedule): static
  306.     {
  307.         if (!$this->groupMatchSchedules->contains($schedule)) {
  308.             $this->groupMatchSchedules->add($schedule);
  309.             $schedule->setOrganizer($this);
  310.         }
  311.         return $this;
  312.     }
  313.     public function removeGroupMatchSchedule(GroupMatchSchedule $schedule): static
  314.     {
  315.         if ($this->groupMatchSchedules->removeElement($schedule)) {
  316.             if ($schedule->getOrganizer() === $this) {
  317.                 $schedule->setOrganizer(null);
  318.             }
  319.         }
  320.         return $this;
  321.     }
  322.     /**
  323.      * A visual identifier that represents this user.
  324.      *
  325.      * @see UserInterface
  326.      */
  327.     public function getUserIdentifier(): string
  328.     {
  329.         return (string) $this->username;
  330.     }
  331.     /**
  332.      * @see UserInterface
  333.      */
  334.     public function getRoles(): array
  335.     {
  336.         $roles $this->roles;
  337.         // guarantee every user at least has ROLE_USER
  338.         $roles[] = 'ROLE_USER';
  339.         return array_unique($roles);
  340.     }
  341.     public function setRoles(array $roles): self
  342.     {
  343.         $this->roles $roles;
  344.         return $this;
  345.     }
  346.     /**
  347.      * @see PasswordAuthenticatedUserInterface
  348.      */
  349.     public function getPassword(): string
  350.     {
  351.         return $this->password;
  352.     }
  353.     public function setPassword(string $password): self
  354.     {
  355.         $this->password $password;
  356.         return $this;
  357.     }
  358.     public function getCreatedAt(): ?\DateTimeImmutable
  359.     {
  360.         return $this->createdAt;
  361.     }
  362.     public function getBioShort(): ?string
  363.     {
  364.         return $this->bioShort;
  365.     }
  366.     public function setBioShort(?string $bioShort): self
  367.     {
  368.         $this->bioShort $bioShort;
  369.         return $this;
  370.     }
  371.     public function setCreatedAt(?\DateTimeImmutable $createdAt): self
  372.     {
  373.         $this->createdAt $createdAt;
  374.         return $this;
  375.     }
  376.     /**
  377.      * Returning a salt is only needed, if you are not using a modern
  378.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  379.      *
  380.      * @see UserInterface
  381.      */
  382.     public function getSalt(): ?string
  383.     {
  384.         return null;
  385.     }
  386.     /**
  387.      * @see UserInterface
  388.      */
  389.     public function eraseCredentials()
  390.     {
  391.         // If you store any temporary, sensitive data on the user, clear it here
  392.         // $this->plainPassword = null;
  393.     }
  394.     /**
  395.      * @return Collection<int, Message>
  396.      */
  397.     public function getSourceMessages(): Collection
  398.     {
  399.         return $this->sourceMessages;
  400.     }
  401.     public function addSourceMessage(Message $sourceMessage): self
  402.     {
  403.         if (!$this->sourceMessages->contains($sourceMessage)) {
  404.             $this->sourceMessages[] = $sourceMessage;
  405.             $sourceMessage->setSourceUser($this);
  406.         }
  407.         return $this;
  408.     }
  409.     public function removeSourceMessage(Message $sourceMessage): self
  410.     {
  411.         if ($this->sourceMessages->removeElement($sourceMessage)) {
  412.             // set the owning side to null (unless already changed)
  413.             if ($sourceMessage->getSourceUser() === $this) {
  414.                 $sourceMessage->setSourceUser(null);
  415.             }
  416.         }
  417.         return $this;
  418.     }
  419.     /**
  420.      * @return Collection<int, GroupUser>
  421.      */
  422.     public function getGroupUsers(): Collection
  423.     {
  424.         return $this->groupUsers;
  425.     }
  426.     public function addGroupUser(GroupUser $groupUser): self
  427.     {
  428.         if (!$this->groupUsers->contains($groupUser)) {
  429.             $this->groupUsers[] = $groupUser;
  430.             $groupUser->addConcernedUser($this);
  431.         }
  432.         return $this;
  433.     }
  434.     public function removeGroupUser(GroupUser $groupUser): self
  435.     {
  436.         if ($this->groupUsers->removeElement($groupUser)) {
  437.             $groupUser->removeConcernedUser($this);
  438.         }
  439.         return $this;
  440.     }
  441.     public function getFlux(): ?Flux
  442.     {
  443.         return $this->flux;
  444.     }
  445.     public function setFlux(?Flux $flux): self
  446.     {
  447.         // unset the owning side of the relation if necessary
  448.         if ($flux === null && $this->flux !== null) {
  449.             $this->flux->setUser(null);
  450.         }
  451.         // set the owning side of the relation if necessary
  452.         if ($flux !== null && $flux->getUser() !== $this) {
  453.             $flux->setUser($this);
  454.         }
  455.         $this->flux $flux;
  456.         return $this;
  457.     }
  458.     /**
  459.      * @return Collection<int, Activity>
  460.      */
  461.     public function getSourceAtivities(): Collection
  462.     {
  463.         return $this->sourceAtivities;
  464.     }
  465.     public function addSourceAtivity(Activity $sourceAtivity): self
  466.     {
  467.         if (!$this->sourceAtivities->contains($sourceAtivity)) {
  468.             $this->sourceAtivities[] = $sourceAtivity;
  469.             $sourceAtivity->setInitialUser($this);
  470.         }
  471.         return $this;
  472.     }
  473.     public function removeSourceAtivity(Activity $sourceAtivity): self
  474.     {
  475.         if ($this->sourceAtivities->removeElement($sourceAtivity)) {
  476.             // set the owning side to null (unless already changed)
  477.             if ($sourceAtivity->getInitialUser() === $this) {
  478.                 $sourceAtivity->setInitialUser(null);
  479.             }
  480.         }
  481.         return $this;
  482.     }
  483.     /**
  484.      * @return Collection<int, Activity>
  485.      */
  486.     public function getTargetActivities(): Collection
  487.     {
  488.         return $this->targetActivities;
  489.     }
  490.     public function addTargetActivity(Activity $targetActivity): self
  491.     {
  492.         if (!$this->targetActivities->contains($targetActivity)) {
  493.             $this->targetActivities[] = $targetActivity;
  494.             // $targetActivity->addTargetUser($this);
  495.         }
  496.         return $this;
  497.     }
  498.     /** TODO : Retiser du groupeUser de l'activité (avec une requete SQL dans le Repository) */
  499.     // TODO : Retiser du groupeUser de l'activité (avec une requete SQL dans le Repository)
  500.     // public function removeTargetActivity(Activity $targetActivity): self
  501.     // {
  502.     //     if ($this->targetActivities->removeElement($targetActivity)) {
  503.     //         $targetActivity->removeTargetUser($this);
  504.     //     }
  505.     //     return $this;
  506.     // }
  507.     /**
  508.      * @return Collection<int, Notification>
  509.      */
  510.     public function getSourceNotifications(): Collection
  511.     {
  512.         return $this->sourceNotifications;
  513.     }
  514.     public function addSourceNotification(Notification $sourceNotification): self
  515.     {
  516.         if (!$this->sourceNotifications->contains($sourceNotification)) {
  517.             $this->sourceNotifications[] = $sourceNotification;
  518.             $sourceNotification->setSourceUser($this);
  519.         }
  520.         return $this;
  521.     }
  522.     public function removeSourceNotification(Notification $sourceNotification): self
  523.     {
  524.         if ($this->sourceNotifications->removeElement($sourceNotification)) {
  525.             // set the owning side to null (unless already changed)
  526.             if ($sourceNotification->getSourceUser() === $this) {
  527.                 $sourceNotification->setSourceUser(null);
  528.             }
  529.         }
  530.         return $this;
  531.     }
  532.     /**
  533.      * @return Collection<int, Notification>
  534.      */
  535.     public function getTargetNotifications(): Collection
  536.     {
  537.         return $this->targetNotifications;
  538.     }
  539.     public function addTargetNotification(Notification $targetNotification): self
  540.     {
  541.         if (!$this->targetNotifications->contains($targetNotification)) {
  542.             $this->targetNotifications[] = $targetNotification;
  543.             $targetNotification->setTargetUser($this);
  544.         }
  545.         return $this;
  546.     }
  547.     public function removeTargetNotification(Notification $targetNotification): self
  548.     {
  549.         if ($this->targetNotifications->removeElement($targetNotification)) {
  550.             // set the owning side to null (unless already changed)
  551.             if ($targetNotification->getTargetUser() === $this) {
  552.                 $targetNotification->setTargetUser(null);
  553.             }
  554.         }
  555.         return $this;
  556.     }
  557.     public function getAuthToken(): ?string
  558.     {
  559.         return $this->authToken;
  560.     }
  561.     public function setAuthToken(?string $authToken): self
  562.     {
  563.         $this->authToken $authToken;
  564.         return $this;
  565.     }
  566.     public function getImage(): ?string
  567.     {
  568.         return $this->image;
  569.     }
  570.     public function setImage(?string $image): self
  571.     {
  572.         $this->image $image;
  573.         return $this;
  574.     }
  575.     public function getRelationGroupUser(): ?GroupUser
  576.     {
  577.         return $this->relationGroupUser;
  578.     }
  579.     public function setRelationGroupUser(?GroupUser $relationGroupUser): self
  580.     {
  581.         $this->relationGroupUser $relationGroupUser;
  582.         return $this;
  583.     }
  584.     public function getUsername(): string
  585.     {
  586.         return $this->username;
  587.     }
  588.     public function setUsername(string $username): self
  589.     {
  590.         $this->username $username;
  591.         return $this;
  592.     }
  593.     public function getPayData(): ?string
  594.     {
  595.         return $this->payData;
  596.     }
  597.     public function setPayData(?string $payData): self
  598.     {
  599.         $this->payData $payData;
  600.         return $this;
  601.     }
  602.     public function isIsActif(): ?bool
  603.     {
  604.         return $this->isActif;
  605.     }
  606.     public function setIsActif(?bool $isActif): static
  607.     {
  608.         $this->isActif $isActif;
  609.         return $this;
  610.     }
  611.     /**
  612.      * @return array<int, string>
  613.      */
  614.     public function getAvailabilitySlots(): array
  615.     {
  616.         return $this->normalizeAvailabilitySlots($this->availabilitySlots ?? []);
  617.     }
  618.     /**
  619.      * @param array<int, string> $availabilitySlots
  620.      */
  621.     public function setAvailabilitySlots(array $availabilitySlots): self
  622.     {
  623.         $this->availabilitySlots $this->normalizeAvailabilitySlots($availabilitySlots);
  624.         $this->availabilityUpdatedAt = new \DateTimeImmutable();
  625.         return $this;
  626.     }
  627.     public function getAvailabilityUpdatedAt(): ?\DateTimeImmutable
  628.     {
  629.         return $this->availabilityUpdatedAt;
  630.     }
  631.     /**
  632.      * @param array<int, string> $slots
  633.      * @return array<int, string>
  634.      */
  635.     private function normalizeAvailabilitySlots(array $slots): array
  636.     {
  637.         $normalized = [];
  638.         foreach ($slots as $slot) {
  639.             $value mb_strtolower(trim((string) $slot));
  640.             if ($value !== '' && in_array($valueself::AVAILABILITY_SLOTStrue)) {
  641.                 $normalized[] = $value;
  642.             }
  643.         }
  644.         $normalized array_values(array_unique($normalized));
  645.         if (empty($normalized)) {
  646.             return [];
  647.         }
  648.         $order array_flip(self::AVAILABILITY_SLOTS);
  649.         usort($normalized, static fn (string $leftstring $right): int => $order[$left] <=> $order[$right]);
  650.         return $normalized;
  651.     }
  652.     /**
  653.      * @return Collection<int, Payment>
  654.      */
  655.     public function getPayments(): Collection
  656.     {
  657.         return $this->payments;
  658.     }
  659.     public function addPayment(Payment $payment): static
  660.     {
  661.         if (!$this->payments->contains($payment)) {
  662.             $this->payments->add($payment);
  663.             $payment->setSourceUser($this);
  664.         }
  665.         return $this;
  666.     }
  667.     public function removePayment(Payment $payment): static
  668.     {
  669.         if ($this->payments->removeElement($payment)) {
  670.             // set the owning side to null (unless already changed)
  671.             if ($payment->getSourceUser() === $this) {
  672.                 $payment->setSourceUser(null);
  673.             }
  674.         }
  675.         return $this;
  676.     }
  677.     public function isIsConfirmed(): ?bool
  678.     {
  679.         return $this->isConfirmed;
  680.     }
  681.     public function setIsConfirmed(?bool $isConfirmed): static
  682.     {
  683.         $this->isConfirmed $isConfirmed;
  684.         return $this;
  685.     }
  686.     public function getPosition(): ?array
  687.     {
  688.         return $this->position;
  689.     }
  690.     public function setPosition(?array $position): static
  691.     {
  692.         $this->position $position;
  693.         return $this;
  694.     }
  695.     public function isLocationOptIn(): bool
  696.     {
  697.         return $this->locationOptIn;
  698.     }
  699.     public function setLocationOptIn(bool $locationOptIn): self
  700.     {
  701.         $this->locationOptIn $locationOptIn;
  702.         return $this;
  703.     }
  704.     public function getLocationUpdatedAt(): ?\DateTimeImmutable
  705.     {
  706.         return $this->locationUpdatedAt;
  707.     }
  708.     public function setLocationUpdatedAt(?\DateTimeImmutable $locationUpdatedAt): self
  709.     {
  710.         $this->locationUpdatedAt $locationUpdatedAt;
  711.         return $this;
  712.     }
  713.     public function getRequirements(): array
  714.     {
  715.         return $this->requirements ?? [];
  716.     }
  717.     public function setRequirements(?array $requirements): static
  718.     {
  719.         $this->requirements $requirements ?? [];
  720.         return $this;
  721.     }
  722.     public function isPremium(): bool
  723.     {
  724.         return (bool) $this->isPremium;
  725.     }
  726.     public function setIsPremium(bool $isPremium): static
  727.     {
  728.         $this->isPremium $isPremium;
  729.         return $this;
  730.     }
  731.     /**
  732.      * @return Collection<int, Reservation>
  733.      */
  734.     public function getReservations(): Collection
  735.     {
  736.         return $this->reservations;
  737.     }
  738.     public function addReservation(Reservation $reservation): static
  739.     {
  740.         if (!$this->reservations->contains($reservation)) {
  741.             $this->reservations->add($reservation);
  742.             $reservation->setUser($this);
  743.         }
  744.         return $this;
  745.     }
  746.     public function removeReservation(Reservation $reservation): static
  747.     {
  748.         if ($this->reservations->removeElement($reservation)) {
  749.             // set the owning side to null (unless already changed)
  750.             if ($reservation->getUser() === $this) {
  751.                 $reservation->setUser(null);
  752.             }
  753.         }
  754.         return $this;
  755.     }
  756.     public function getBackgroundImage(): ?string
  757.     {
  758.         return $this->backgroundImage;
  759.     }
  760.     public function setBackgroundImage(?string $backgroundImage): static
  761.     {
  762.         $this->backgroundImage $backgroundImage;
  763.         return $this;
  764.     }
  765.     public function getAccount(): ?Account
  766.     {
  767.         return $this->account;
  768.     }
  769.     public function setAccount(?Account $account): static
  770.     {
  771.         // unset the owning side of the relation if necessary
  772.         if ($account === null && $this->account !== null) {
  773.             $this->account->setOwner(null);
  774.         }
  775.         // set the owning side of the relation if necessary
  776.         if ($account !== null && $account->getOwner() !== $this) {
  777.             $account->setOwner($this);
  778.         }
  779.         $this->account $account;
  780.         return $this;
  781.     }
  782. }