src/Entity/User.php line 29

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\ActiveTrait;
  4. use App\Entity\Traits\AddressTrait;
  5. use App\Entity\Traits\ErrorTrait;
  6. use App\Entity\Traits\OnbeTrait;
  7. use App\Entity\Traits\W9Trait;
  8. use App\Entity\Traits\W8Trait;
  9. use App\Repository\UserRepository;
  10. use Doctrine\Common\Collections\Criteria;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Gedmo\Timestampable\Traits\TimestampableEntity;
  15. use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface;
  16. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  17. use Symfony\Component\Security\Core\Security;
  18. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  19. use Symfony\Component\Security\Core\User\UserInterface;
  20. use Symfony\Component\Validator\Constraints as Assert;
  21. /**
  22. * @ORM\Entity(repositoryClass=UserRepository::class)
  23. * @ORM\Table(name="`user`")
  24. * @UniqueEntity(fields={"email"}, message="This email is already registered in Jewelry Rewards. Please click SIGN IN in the top navigation to sign in or reset your password.")
  25. */
  26. class User implements UserInterface, PasswordAuthenticatedUserInterface, TwoFactorInterface
  27. {
  28. use ActiveTrait;
  29. use AddressTrait;
  30. use W9Trait;
  31. use W8Trait;
  32. use OnbeTrait;
  33. use ErrorTrait;
  34. use TimestampableEntity;
  35. public const ROLE_DEFAULT = 'ROLE_USER';
  36. public const ROLE_SUPER_ADMIN = 'ROLE_SUPER_ADMIN';
  37. public const ROLE_ADMIN = 'ROLE_ADMIN';
  38. public const ROLE_CORP_ADMIN = 'ROLE_CORP_ADMIN';
  39. public const ROLE_MK_CORP_ADMIN = 'ROLE_MK_CORP_ADMIN';
  40. /**
  41. * @ORM\Id
  42. * @ORM\GeneratedValue
  43. * @ORM\Column(type="integer")
  44. */
  45. private $id;
  46. /**
  47. * @ORM\Column(type="string", length=180, unique=true)
  48. */
  49. private $email;
  50. /**
  51. * @ORM\Column(type="json")
  52. */
  53. private $roles = [];
  54. /**
  55. * @var string The hashed password
  56. * @ORM\Column(type="string")
  57. */
  58. private $password;
  59. public $plainPassword;
  60. /**
  61. * @ORM\Column(type="string", length=255, nullable=true)
  62. */
  63. private $firstName;
  64. /**
  65. * @ORM\Column(type="string", length=255, nullable=true)
  66. */
  67. private $lastName;
  68. /**
  69. * @ORM\Column(type="string", length=255, nullable=true)
  70. * @Assert\Regex(pattern="/(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}/", message="Phone number is not valid")
  71. */
  72. private $phone;
  73. /**
  74. * @ORM\OneToMany(targetEntity=Submission::class, mappedBy="user", orphanRemoval=true)
  75. */
  76. private $submissions;
  77. private $newEmail = null;
  78. private $termsAccepted = false;
  79. public $invitationCode;
  80. public $retailer;
  81. public $retailerName;
  82. public $brand;
  83. /**
  84. * @ORM\Column(type="string", length=500, nullable=true)
  85. */
  86. private $ssn;
  87. /**
  88. * @ORM\Column(type="string", length=255, nullable=true)
  89. */
  90. private $workEmail;
  91. /**
  92. * @ORM\OneToMany(targetEntity=UserInvitationCode::class, mappedBy="user", orphanRemoval=true, cascade={"persist"})
  93. */
  94. private $userInvitationCodes;
  95. /**
  96. * @ORM\OneToMany(targetEntity=EducationQuizResult::class, mappedBy="user")
  97. */
  98. private $educationQuizResults;
  99. /**
  100. * @ORM\OneToMany(targetEntity=EducationUserHistory::class, mappedBy="user")
  101. */
  102. private $educationUserHistories;
  103. /**
  104. * @ORM\OneToMany(targetEntity=Reward::class, mappedBy="user", orphanRemoval=true)
  105. */
  106. private $rewards;
  107. /**
  108. * @ORM\Column(type="boolean")
  109. */
  110. private $optOut = false;
  111. /**
  112. * @ORM\OneToMany(targetEntity=OnbeTransaction::class, mappedBy="user", orphanRemoval=true)
  113. */
  114. private $onbeTransactions;
  115. private $loggedUser = null;
  116. /**
  117. * @ORM\OneToMany(targetEntity=UserRetailer::class, mappedBy="user", orphanRemoval=true, cascade={"all"})
  118. */
  119. private $userRetailers;
  120. /**
  121. * @ORM\OneToMany(targetEntity=ImportFile::class, mappedBy="user")
  122. */
  123. private $importFiles;
  124. /**
  125. * @ORM\Column(type="string", length=500, nullable=true)
  126. */
  127. private $authCode;
  128. /**
  129. * @ORM\Column(type="boolean")
  130. */
  131. private $completed = true;
  132. /**
  133. * @ORM\Column(type="integer", nullable=true)
  134. */
  135. private $external_id;
  136. /**
  137. * @ORM\Column(type="string", length=255, nullable=true)
  138. */
  139. private $store_id;
  140. /**
  141. * @ORM\OneToMany(targetEntity=OnbeAccount::class, mappedBy="user", cascade={"all"})
  142. */
  143. private $onbeAccounts;
  144. public function __construct()
  145. {
  146. $this->submissions = new ArrayCollection();
  147. $this->userInvitationCodes = new ArrayCollection();
  148. $this->educationQuizResults = new ArrayCollection();
  149. $this->educationUserHistories = new ArrayCollection();
  150. $this->rewards = new ArrayCollection();
  151. $this->onbeTransactions = new ArrayCollection();
  152. $this->userRetailers = new ArrayCollection();
  153. $this->importFiles = new ArrayCollection();
  154. $this->onbeAccounts = new ArrayCollection();
  155. }
  156. public function getId(): ?int
  157. {
  158. return $this->id;
  159. }
  160. public function getEmail(): ?string
  161. {
  162. return $this->email;
  163. }
  164. public function setEmail(string $email): self
  165. {
  166. $this->email = $email;
  167. return $this;
  168. }
  169. /**
  170. * A visual identifier that represents this user.
  171. *
  172. * @see UserInterface
  173. */
  174. public function getUserIdentifier(): string
  175. {
  176. return (string) $this->email;
  177. }
  178. /**
  179. * @deprecated since Symfony 5.3, use getUserIdentifier instead
  180. */
  181. public function getUsername(): string
  182. {
  183. return (string) $this->email;
  184. }
  185. /**
  186. * @see UserInterface
  187. */
  188. public function getRoles(): array
  189. {
  190. $roles = $this->roles;
  191. // guarantee every user at least has ROLE_USER
  192. $roles[] = 'ROLE_USER';
  193. if (in_array(strtoupper(self::ROLE_CORP_ADMIN), $roles, true)){
  194. foreach ($this->getUserBrands() as $brand){
  195. if ($brand->getName() == 'MK Diamonds'){
  196. $roles[] = self::ROLE_MK_CORP_ADMIN;
  197. break;
  198. }
  199. }
  200. }
  201. return array_unique($roles);
  202. }
  203. public function setRoles(array $roles): self
  204. {
  205. $this->roles = $roles;
  206. return $this;
  207. }
  208. /**
  209. * {@inheritdoc}
  210. */
  211. public function hasRole($role): bool
  212. {
  213. return in_array(strtoupper($role), $this->getRoles(), true);
  214. }
  215. /**
  216. * @see PasswordAuthenticatedUserInterface
  217. */
  218. public function getPassword(): string
  219. {
  220. return $this->password;
  221. }
  222. public function setPassword(string $password): self
  223. {
  224. $this->password = $password;
  225. return $this;
  226. }
  227. public function addRole($role): self
  228. {
  229. $roles = $this->roles;
  230. $roles[] = $role;
  231. $this->setRoles(array_unique($roles));
  232. return $this;
  233. }
  234. public static function getRolesList(): array
  235. {
  236. return [
  237. self::ROLE_DEFAULT => 'User',
  238. self::ROLE_SUPER_ADMIN => 'Super Admin',
  239. self::ROLE_ADMIN => 'Admin',
  240. self::ROLE_CORP_ADMIN => 'Corporate Admin',
  241. self::ROLE_MK_CORP_ADMIN => 'MK Corporate Admin',
  242. ];
  243. }
  244. public function getRolesLabels(): string
  245. {
  246. $rolesList = self::getRolesList();
  247. $roles = [];
  248. foreach ($this->getRoles() as $role){
  249. if($role !== self::ROLE_DEFAULT){
  250. $roles[] = "<span class='label label-info'>{$rolesList[$role]}</span>&nbsp;";
  251. }
  252. }
  253. return implode(' ', $roles);
  254. }
  255. /**
  256. * Returning a salt is only needed, if you are not using a modern
  257. * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  258. *
  259. * @see UserInterface
  260. */
  261. public function getSalt(): ?string
  262. {
  263. return null;
  264. }
  265. /**
  266. * @see UserInterface
  267. */
  268. public function eraseCredentials()
  269. {
  270. // If you store any temporary, sensitive data on the user, clear it here
  271. // $this->plainPassword = null;
  272. }
  273. public function getFirstName(): ?string
  274. {
  275. return $this->firstName;
  276. }
  277. public function setFirstName(?string $firstName): self
  278. {
  279. $this->firstName = $firstName;
  280. return $this;
  281. }
  282. public function getLastName(): ?string
  283. {
  284. return $this->lastName;
  285. }
  286. public function setLastName(?string $lastName): self
  287. {
  288. $this->lastName = $lastName;
  289. return $this;
  290. }
  291. public function getPhone(): ?string
  292. {
  293. return $this->phone;
  294. }
  295. public function setPhone(?string $phone): self
  296. {
  297. $this->phone = $phone;
  298. return $this;
  299. }
  300. /**
  301. * @return string|null
  302. */
  303. public function getFullName(): string
  304. {
  305. return sprintf('%s %s',$this->getFirstName(), $this->getLastName());
  306. }
  307. /**
  308. * @return Collection<int, Submission>
  309. */
  310. public function getSubmissions(): Collection
  311. {
  312. return $this->submissions;
  313. }
  314. public function addSubmission(Submission $submission): self
  315. {
  316. if (!$this->submissions->contains($submission)) {
  317. $this->submissions[] = $submission;
  318. $submission->setUser($this);
  319. }
  320. return $this;
  321. }
  322. public function removeSubmission(Submission $submission): self
  323. {
  324. if ($this->submissions->removeElement($submission)) {
  325. // set the owning side to null (unless already changed)
  326. if ($submission->getUser() === $this) {
  327. $submission->setUser(null);
  328. }
  329. }
  330. return $this;
  331. }
  332. public function getSsn(): ?string
  333. {
  334. return $this->ssn;
  335. }
  336. public function setSsn(?string $ssn): self
  337. {
  338. $this->ssn = $ssn;
  339. return $this;
  340. }
  341. /**
  342. * @return null
  343. */
  344. public function getNewEmail()
  345. {
  346. return $this->newEmail;
  347. }
  348. /**
  349. * @param null $newEmail
  350. */
  351. public function setNewEmail($newEmail): void
  352. {
  353. $this->newEmail = $newEmail;
  354. }
  355. /**
  356. * @return bool
  357. */
  358. public function isTermsAccepted(): bool
  359. {
  360. return $this->termsAccepted;
  361. }
  362. /**
  363. * @param bool $termsAccepted
  364. */
  365. public function setTermsAccepted(bool $termsAccepted): void
  366. {
  367. $this->termsAccepted = $termsAccepted;
  368. }
  369. public function getWorkEmail(): ?string
  370. {
  371. return $this->workEmail;
  372. }
  373. public function setWorkEmail(?string $workEmail): self
  374. {
  375. $this->workEmail = $workEmail;
  376. return $this;
  377. }
  378. /**
  379. * @return Collection<int, UserInvitationCode>
  380. */
  381. public function getUserInvitationCodes(User $user = null): Collection
  382. {
  383. /**
  384. * I need it because I cannot override sonata admin's export logic
  385. *
  386. */
  387. $user = $this->getLoggedUser();
  388. if ($user && $user->hasRole(self::ROLE_CORP_ADMIN)){
  389. $userBrands = $user->getUserBrands();
  390. return $this->userInvitationCodes->filter(function (UserInvitationCode $userInvitationCode) use ($userBrands){
  391. return isset($userBrands[$userInvitationCode->getInvitationCode()->getBrand()->getId()]);
  392. });
  393. }
  394. return $this->userInvitationCodes;
  395. }
  396. public function addUserInvitationCode(UserInvitationCode $userInvitationCode): self
  397. {
  398. if (!$this->userInvitationCodes->contains($userInvitationCode)) {
  399. $this->userInvitationCodes[] = $userInvitationCode;
  400. $userInvitationCode->setUser($this);
  401. }
  402. return $this;
  403. }
  404. public function setUserInvitationCodes($userInvitationCodes): self
  405. {
  406. $this->userInvitationCodes = $userInvitationCodes;
  407. return $this;
  408. }
  409. public function removeUserInvitationCode(UserInvitationCode $userInvitationCode): self
  410. {
  411. if ($this->userInvitationCodes->removeElement($userInvitationCode)) {
  412. // set the owning side to null (unless already changed)
  413. if ($userInvitationCode->getUser() === $this) {
  414. $userInvitationCode->setUser(null);
  415. }
  416. }
  417. return $this;
  418. }
  419. public function __toString()
  420. {
  421. return (string)$this->getFullName();
  422. }
  423. /**
  424. * @param User|null $user
  425. * @return array
  426. */
  427. public function getUserBrands(User $user = null): array
  428. {
  429. $brands = [];
  430. foreach ($this->getUserRetailers() as $userRetailer){
  431. if ($userRetailer->isApproved()){
  432. // First check if UserRetailer has a direct brand association
  433. if ($userRetailer->getBrand()) {
  434. $brand = $userRetailer->getBrand();
  435. $brands[$brand->getId()] = $brand;
  436. }
  437. // Otherwise, check store brands
  438. /*elseif ($userRetailer->getStore() && $userRetailer->getStore()->getActive()) {
  439. foreach ($userRetailer->getStore()->getBrands() as $brand) {
  440. $brands[$brand->getId()] = $brand;
  441. }
  442. }
  443. // Fallback to legacy retailer brand
  444. elseif ($userRetailer->getRetailer() && $userRetailer->getRetailer()->getActive()) {
  445. $brand = $userRetailer->getRetailer()->getBrand();
  446. if ($brand) {
  447. $brands[$brand->getId()] = $brand;
  448. }
  449. }*/
  450. }
  451. }
  452. return $brands;
  453. }
  454. public function getDefaultBrand(): ?Brand
  455. {
  456. if (count($this->getUserInvitationCodes()) === 1){
  457. return $this->getUserInvitationCodes()->first()->getInvitationCode()->getBrand();
  458. }
  459. return null;
  460. }
  461. /**
  462. * @param User|null $user
  463. * @return array
  464. */
  465. public function getUserRetailersOld(User $user = null): array
  466. {
  467. $retailers = [];
  468. foreach ($this->getUserInvitationCodes($user) as $userInvitationCode){
  469. $retailer = $userInvitationCode->getInvitationCode()->getRetailer();
  470. $retailers[$retailer->getId()] = $retailer;
  471. }
  472. return $retailers;
  473. }
  474. /**
  475. * @return Collection<int, EducationQuizResult>
  476. */
  477. public function getEducationQuizResults(): Collection
  478. {
  479. return $this->educationQuizResults;
  480. }
  481. public function addEducationQuizResult(EducationQuizResult $educationQuizResult): self
  482. {
  483. if (!$this->educationQuizResults->contains($educationQuizResult)) {
  484. $this->educationQuizResults[] = $educationQuizResult;
  485. $educationQuizResult->setUser($this);
  486. }
  487. return $this;
  488. }
  489. public function removeEducationQuizResult(EducationQuizResult $educationQuizResult): self
  490. {
  491. if ($this->educationQuizResults->removeElement($educationQuizResult)) {
  492. // set the owning side to null (unless already changed)
  493. if ($educationQuizResult->getUser() === $this) {
  494. $educationQuizResult->setUser(null);
  495. }
  496. }
  497. return $this;
  498. }
  499. /**
  500. * @return Collection<int, EducationUserHistory>
  501. */
  502. public function getEducationUserHistories(): Collection
  503. {
  504. return $this->educationUserHistories;
  505. }
  506. public function addEducationUserHistory(EducationUserHistory $educationUserHistory): self
  507. {
  508. if (!$this->educationUserHistories->contains($educationUserHistory)) {
  509. $this->educationUserHistories[] = $educationUserHistory;
  510. $educationUserHistory->setUser($this);
  511. }
  512. return $this;
  513. }
  514. public function removeEducationUserHistory(EducationUserHistory $educationUserHistory): self
  515. {
  516. if ($this->educationUserHistories->removeElement($educationUserHistory)) {
  517. // set the owning side to null (unless already changed)
  518. if ($educationUserHistory->getUser() === $this) {
  519. $educationUserHistory->setUser(null);
  520. }
  521. }
  522. return $this;
  523. }
  524. /**
  525. * @return Collection<int, Reward>
  526. */
  527. public function getRewards(): Collection
  528. {
  529. return $this->rewards;
  530. }
  531. public function addReward(Reward $reward): self
  532. {
  533. if (!$this->rewards->contains($reward)) {
  534. $this->rewards[] = $reward;
  535. $reward->setUser($this);
  536. }
  537. return $this;
  538. }
  539. public function removeReward(Reward $reward): self
  540. {
  541. if ($this->rewards->removeElement($reward)) {
  542. // set the owning side to null (unless already changed)
  543. if ($reward->getUser() === $this) {
  544. $reward->setUser(null);
  545. }
  546. }
  547. return $this;
  548. }
  549. /**
  550. * @return bool
  551. */
  552. public function isOptOut(): ?bool
  553. {
  554. return $this->optOut;
  555. }
  556. /**
  557. * @param bool $optOut
  558. * @return User
  559. */
  560. public function setOptOut(bool $optOut): self
  561. {
  562. $this->optOut = $optOut;
  563. return $this;
  564. }
  565. public function getPaidRewardsAmount()
  566. {
  567. $paidRewards = 0;
  568. foreach ($this->getRewards() as $reward){
  569. if($reward->getStatus() == Reward::STATUS_PAID){
  570. $paidRewards += $reward->getAmount();
  571. }
  572. }
  573. return $paidRewards;
  574. }
  575. public function getTotalRewardsAmount()
  576. {
  577. $totalRewards = 0;
  578. foreach ($this->getRewards() as $reward){
  579. $totalRewards += $reward->getAmount();
  580. }
  581. return $totalRewards;
  582. }
  583. public function hasRetailerProducts($brand = null): bool
  584. {
  585. foreach ($this->getUserRetailers() as $userRetailer){
  586. if($brand && $userRetailer->getBrand()->getId() !== $brand->getId()){
  587. continue;
  588. }
  589. if (count($userRetailer->getStore()->getRetailer()->getProducts()) > 0){
  590. return true;
  591. }
  592. }
  593. return false;
  594. }
  595. /**
  596. * @return Collection<int, OnbeTransaction>
  597. */
  598. public function getOnbeTransactions(): Collection
  599. {
  600. return $this->onbeTransactions;
  601. }
  602. public function addOnbeTransaction(OnbeTransaction $onbeTransaction): self
  603. {
  604. if (!$this->onbeTransactions->contains($onbeTransaction)) {
  605. $this->onbeTransactions[] = $onbeTransaction;
  606. $onbeTransaction->setUser($this);
  607. }
  608. return $this;
  609. }
  610. public function removeOnbeTransaction(OnbeTransaction $onbeTransaction): self
  611. {
  612. if ($this->onbeTransactions->removeElement($onbeTransaction)) {
  613. // set the owning side to null (unless already changed)
  614. if ($onbeTransaction->getUser() === $this) {
  615. $onbeTransaction->setUser(null);
  616. }
  617. }
  618. return $this;
  619. }
  620. public function setLoggedUser(UserInterface $user)
  621. {
  622. $this->loggedUser = $user;
  623. }
  624. public function getLoggedUser()
  625. {
  626. return $this->loggedUser;
  627. }
  628. /**
  629. * @return Collection<int, UserRetailer>
  630. */
  631. public function getUserRetailers(): Collection
  632. {
  633. return $this->userRetailers;
  634. }
  635. public function addUserRetailer(UserRetailer $userRetailer): self
  636. {
  637. if (!$this->userRetailers->contains($userRetailer)) {
  638. $this->userRetailers[] = $userRetailer;
  639. $userRetailer->setUser($this);
  640. }
  641. return $this;
  642. }
  643. public function removeUserRetailer(UserRetailer $userRetailer): self
  644. {
  645. if ($this->userRetailers->removeElement($userRetailer)) {
  646. // set the owning side to null (unless already changed)
  647. if ($userRetailer->getUser() === $this) {
  648. $userRetailer->setUser(null);
  649. }
  650. }
  651. return $this;
  652. }
  653. public function hasBrandAccess(Brand $brand): bool
  654. {
  655. return isset($this->getUserBrands()[$brand->getId()]);
  656. }
  657. /**
  658. * @return mixed
  659. */
  660. public function getUnMaskedSsn()
  661. {
  662. return $this->unMaskedSsn;
  663. }
  664. /**
  665. * @return Reward
  666. */
  667. public function getTotalRewards()
  668. {
  669. if($this->getRewards() === null){
  670. return 0;
  671. }
  672. $criteria = Criteria::create()
  673. ->andWhere(Criteria::expr()->eq('status', Reward::STATUS_PAID))
  674. ->andWhere(Criteria::expr()->gte('paidAt', new \DateTime('2023-01-01')))
  675. ;
  676. $rewards = $this->getRewards()->matching($criteria);
  677. $total = 0;
  678. foreach ($rewards as $reward){
  679. $total += $reward->getAmount();
  680. }
  681. return $total;
  682. }
  683. /**
  684. * @return Collection<int, ImportFile>
  685. */
  686. public function getImportFiles(): Collection
  687. {
  688. return $this->importFiles;
  689. }
  690. public function addImportFile(ImportFile $importFile): self
  691. {
  692. if (!$this->importFiles->contains($importFile)) {
  693. $this->importFiles[] = $importFile;
  694. $importFile->setUser($this);
  695. }
  696. return $this;
  697. }
  698. public function removeImportFile(ImportFile $importFile): self
  699. {
  700. if ($this->importFiles->removeElement($importFile)) {
  701. // set the owning side to null (unless already changed)
  702. if ($importFile->getUser() === $this) {
  703. $importFile->setUser(null);
  704. }
  705. }
  706. return $this;
  707. }
  708. public function isAdmin(): bool
  709. {
  710. return $this->hasRole(self::ROLE_SUPER_ADMIN) || $this->hasRole(self::ROLE_ADMIN) || $this->hasRole(self::ROLE_CORP_ADMIN) || $this->hasRole(self::ROLE_MK_CORP_ADMIN);
  711. }
  712. public function isEmailAuthEnabled(): bool
  713. {
  714. return false;
  715. return $this->isAdmin();
  716. }
  717. public function getEmailAuthRecipient(): string
  718. {
  719. return $this->email;
  720. }
  721. public function getEmailAuthCode(): string
  722. {
  723. if (null === $this->authCode) {
  724. throw new \LogicException('The authentication code was not set');
  725. }
  726. return $this->authCode;
  727. }
  728. public function setEmailAuthCode(string $authCode): void
  729. {
  730. $this->authCode = $authCode;
  731. }
  732. public function getCompleted(): ?bool
  733. {
  734. return $this->completed;
  735. }
  736. public function setCompleted(bool $completed): self
  737. {
  738. $this->completed = $completed;
  739. return $this;
  740. }
  741. public function getExternalId(): ?int
  742. {
  743. return $this->external_id;
  744. }
  745. public function setExternalId(?int $external_id): self
  746. {
  747. $this->external_id = $external_id;
  748. return $this;
  749. }
  750. public function getStoreId(): ?string
  751. {
  752. return $this->store_id;
  753. }
  754. public function setStoreId(?string $store_id): self
  755. {
  756. $this->store_id = $store_id;
  757. return $this;
  758. }
  759. /**
  760. * @return Collection<int, OnbeAccount>
  761. */
  762. public function getOnbeAccounts(): Collection
  763. {
  764. return $this->onbeAccounts;
  765. }
  766. public function addOnbeAccount(OnbeAccount $onbeAccount): self
  767. {
  768. if (!$this->onbeAccounts->contains($onbeAccount)) {
  769. $this->onbeAccounts[] = $onbeAccount;
  770. $onbeAccount->setUser($this);
  771. }
  772. return $this;
  773. }
  774. public function removeOnbeAccount(OnbeAccount $onbeAccount): self
  775. {
  776. if ($this->onbeAccounts->removeElement($onbeAccount)) {
  777. // set the owning side to null (unless already changed)
  778. if ($onbeAccount->getUser() === $this) {
  779. $onbeAccount->setUser(null);
  780. }
  781. }
  782. return $this;
  783. }
  784. }