src/Entity/User.php line 37

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Enums\CompanyRoleEnum;
  4. use App\Enums\CurrencyTypeEnum;
  5. use App\Enums\UserRoleEnum;
  6. use DateTime;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation;
  11. use Serializable;
  12. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  13. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  14. use Symfony\Component\Security\Core\User\UserInterface;
  15. use Symfony\Component\Serializer\Annotation\Ignore;
  16. use Symfony\Component\Validator\Constraints as Validation;
  17. use Doctrine\ORM\Mapping\AttributeOverrides;
  18. use Doctrine\ORM\Mapping\AttributeOverride;
  19. /**
  20.  * @ORM\Table(name="fos_user")
  21.  * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
  22.  */
  23. #[UniqueEntity(
  24.     fields: ['username''email'],
  25.     message'Nalog sa ovim korisničkim imenom već postoji!',
  26.     errorPath'email'
  27. ),
  28.     UniqueEntity(
  29.         fields: ['phoneNumber'],
  30.         message'Ovaj broj telefona već postoji!',
  31.         errorPath'phoneNumber'
  32.     )
  33. ]
  34. class User implements UserInterfacePasswordAuthenticatedUserInterface
  35. {
  36.     public const VRTIC 1798;
  37.     /**
  38.      * @ORM\Id
  39.      * @ORM\Column(type="integer")
  40.      * @ORM\GeneratedValue(strategy="AUTO")
  41.      */
  42.     private int $id;
  43.     /**
  44.      * @ORM\Column(name="username", type="string", length=180)
  45.      */
  46.     private string $username;
  47.     /**
  48.      * @ORM\Column(name="username_canonical", type="string", length=180, unique=true)
  49.      */
  50.     private string $usernameCanonical;
  51.     /**
  52.      * @ORM\Column(name="email", type="string", length=180)
  53.      */
  54.     private string $email;
  55.     /**
  56.      * @ORM\Column(name="email_canonical", type="string", length=180, unique=true)
  57.      */
  58.     private string $emailCanonical;
  59.     /**
  60.      * @ORM\Column(name="enabled", type="boolean")
  61.      */
  62.     private bool $enabled;
  63.     /**
  64.      * @ORM\Column(name="paid_bill", type="integer", options={"default": 1})
  65.      */
  66.     private int $paidBill;
  67.     /**
  68.      * The salt to use for hashing.
  69.      * @ORM\Column(name="salt", type="string", nullable=true)
  70.      */
  71.     private string|null $salt;
  72.     /**
  73.      * Encrypted password. Must be persisted.
  74.      * @ORM\Column(name="password", type="string")
  75.      */
  76.     private string $password;
  77.     /**
  78.      * @ORM\Column(name="last_login", type="datetime", nullable=true)
  79.      */
  80.     private DateTime|null $lastLogin;
  81.     /**
  82.      * Random string sent to the user email address in order to verify it.
  83.      * @ORM\Column(name="confirmation_token", type="string", length=180, unique=true, nullable=true)
  84.      */
  85.     private string|null $confirmationToken;
  86.     /**
  87.      * @ORM\Column(name="password_requested_at", type="datetime", nullable=true)
  88.      */
  89.     private DateTime|null $passwordRequestedAt;
  90.     /**
  91.      * @var array<string>
  92.      * @ORM\Column(name="roles", type="array")
  93.      */
  94.     private array $roles;
  95.     /**
  96.      * @Validation\NotBlank(message="PLEASE_ENTER_FIRSTNAME", groups={"RequireData"})
  97.      * @Validation\Length(
  98.      *     min="2",
  99.      *     max="32",
  100.      *     minMessage="FIRST_NAME_IS_TOO_SHORT",
  101.      *     maxMessage="FIRST_NAME_IS_TOO_LONG",
  102.      *     groups={"RequireData"}
  103.      *     )
  104.      */
  105.     private string|null $plainPassword null;
  106.     /**
  107.      * @Validation\NotBlank(message="PLEASE_ENTER_FIRSTNAME", groups={"RequireData"})
  108.      * @Validation\Length(
  109.      *     min="2",
  110.      *     max="32",
  111.      *     minMessage="FIRST_NAME_IS_TOO_SHORT",
  112.      *     maxMessage="FIRST_NAME_IS_TOO_LONG",
  113.      *     groups={"RequireData"}
  114.      *     )
  115.      * @ORM\Column(name="firstname", type="string", length=255, nullable=true)
  116.      */
  117.     private string|null $firstname;
  118.     /**
  119.      * @Validation\NotBlank(message="PLEASE_ENTER_LASTNAME", groups={"RequireData"})
  120.      * @Validation\Length(
  121.      *     min="2",
  122.      *     max="32",
  123.      *     minMessage="LAST_NAME_IS_TOO_SHORT",
  124.      *     maxMessage="LAST_NAME_IS_TOO_LONG",
  125.      *     groups={"RequireData"}
  126.      *     )
  127.      * @ORM\Column(name="lastname", type="string", length=255, nullable=true)
  128.      */
  129.     private string|null $lastname;
  130.     /**
  131.      * @Validation\NotBlank(message="MUST_ACCEPT_PRIVACY_POLICY", groups={"RequireData"})
  132.      * @ORM\Column(name="has_accepted_terms", type="boolean")
  133.      */
  134.     private bool $hasAcceptedTerms;
  135.     /**
  136.      * @Validation\Length(max="50", maxMessage="ADDRESS_TOO_LONG")
  137.      * @ORM\Column(name="address", type="string", nullable=true)
  138.      * @Validation\NotBlank(message="FIELD_MUST_NOT_BE_EMPTY", groups={"RequireData"})
  139.      */
  140.     private string|null $address null;
  141.     /**
  142.      * @Validation\Length(max="4", maxMessage="STREETNUMBER_TOO_LONG")
  143.      * @ORM\Column(name="streetnumber", type="string", nullable=true)
  144.      * @Validation\NotBlank(message="FIELD_MUST_NOT_BE_EMPTY", groups={"RequireData"})
  145.      */
  146.     private string|null $streetNumber;
  147.     /**
  148.      * @Validation\Length(max="8", maxMessage="ZIP_TOO_LONG")
  149.      * @ORM\Column(name="zip", type="string", nullable=true)
  150.      * @Validation\NotBlank(message="FIELD_MUST_NOT_BE_EMPTY", groups={"RequireData"})
  151.      */
  152.     private string|null $zip;
  153.     /**
  154.      * @Validation\Length(max="100", maxMessage="CITY_IS_TOO_LONG", groups={"RequireData"})
  155.      * @ORM\Column(name="city", type="string", length=255, nullable=true)
  156.      * @Validation\NotBlank(message="FIELD_MUST_NOT_BE_EMPTY", groups={"RequireData"})
  157.      */
  158.     private string|null $city null;
  159.     /**
  160.      * @ORM\Column(name="phone_number", type="string", length=255, nullable=true, unique=true)
  161.      */
  162.     private string|null $phoneNumber null;
  163.     /**
  164.      * @ORM\Column(name="company_name", type="string", length=255, nullable=true, unique=true)
  165.      */
  166.     private string|null $companyName null;
  167.     /**
  168.      * @ORM\Column(name="created_at", type="datetime")
  169.      */
  170.     private DateTime|null $createdAt null;
  171.     /**
  172.      * @ORM\Column(name="updated_at", type="datetime")
  173.      */
  174.     private DateTime|null $updatedAt null;
  175.     /**
  176.      * @ORM\Column(name="mat_id", type="string", length=64, nullable=true)
  177.      */
  178.     private string|null $matId null;
  179.     /**
  180.      * @ORM\Column(name="pib", type="string", length=64, nullable=true)
  181.      */
  182.     private string|null $pib null;
  183.     /**
  184.      * @ORM\Column(name="company_title", type="string", length=255, nullable=true)
  185.      */
  186.     private string|null $companyTitle;
  187.     /**
  188.      * @ORM\Column(name="license_id", type="string", length=64, nullable=true)
  189.      */
  190.     private string|null $licenseId;
  191.     /**
  192.      * @ORM\Column(name="bank_account", type="string", length=128, nullable=true)
  193.      */
  194.     private string|null $bankAccount null;
  195.     /**
  196.      * @ORM\Column(name="enable_qr", type="boolean", options={"default" : true})
  197.      */
  198.     private bool $enableQr true;
  199.     /**
  200.      * @var Collection<int, Obligation>
  201.      * @ORM\OneToMany(targetEntity="App\Entity\Obligation", mappedBy="user")
  202.      */
  203.     #[Ignore]
  204.     private Collection $obligations;
  205.     /**
  206.      * @ORM\Column(name="task_notification_email", type="string", length=180, nullable=true)
  207.      */
  208.     private string|null $taskNotificationEmail;
  209.     /**
  210.      * @ORM\ManyToOne(targetEntity="App\Entity\User", cascade={"persist"})
  211.      * @ORM\JoinColumns({
  212.      *   @ORM\JoinColumn(name="main_user_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
  213.      * })
  214.      */
  215.     #[Ignore]
  216.     private User|null $mainUser null;
  217.     /**
  218.      * @var Collection<int, ActionLog>
  219.      * @ORM\OneToMany(targetEntity=ActionLog::class, mappedBy="user")
  220.      */
  221.     #[Ignore]
  222.     private Collection $actionLogs;
  223.     /**
  224.      * @ORM\Column(type="string", length=3, options={"default": "RSD"})
  225.      */
  226.     private string $currency 'RSD';
  227.     public function __construct()
  228.     {
  229.         $this->enabled false;
  230.         $this->paidBill 1;
  231.         $this->roles = array();
  232.         $this->obligations = new ArrayCollection();
  233.         $this->actionLogs = new ArrayCollection();
  234.         $this->incrementCreatedAt();
  235.     }
  236.     /**
  237.      * @return int
  238.      */
  239.     public function getId(): int
  240.     {
  241.         return $this->id;
  242.     }
  243.     /**
  244.      * @return string
  245.      */
  246.     public function getUsername(): string
  247.     {
  248.         return $this->username;
  249.     }
  250.     /**
  251.      * @param string $username
  252.      */
  253.     public function setUsername(string $username): void
  254.     {
  255.         $this->username $username;
  256.     }
  257.     /**
  258.      * @return string
  259.      */
  260.     public function getUsernameCanonical(): string
  261.     {
  262.         return $this->usernameCanonical;
  263.     }
  264.     /**
  265.      * @param string $usernameCanonical
  266.      */
  267.     public function setUsernameCanonical(string $usernameCanonical): void
  268.     {
  269.         $this->usernameCanonical $usernameCanonical;
  270.     }
  271.     /**
  272.      * @return string
  273.      */
  274.     public function getEmail(): string
  275.     {
  276.         return $this->email;
  277.     }
  278.     /**
  279.      * @param string $email
  280.      */
  281.     public function setEmail(string $email): void
  282.     {
  283.         $this->setUsername($email);
  284.         $this->email $email;
  285.     }
  286.     /**
  287.      * @return string
  288.      */
  289.     public function getEmailCanonical(): string
  290.     {
  291.         return $this->emailCanonical;
  292.     }
  293.     /**
  294.      * @param string $emailCanonical
  295.      */
  296.     public function setEmailCanonical(string $emailCanonical): void
  297.     {
  298.         $this->emailCanonical $emailCanonical;
  299.     }
  300.     /**
  301.      * @return bool
  302.      */
  303.     public function isEnabled(): bool
  304.     {
  305.         return $this->enabled;
  306.     }
  307.     /**
  308.      * @return bool
  309.      */
  310.     public function isSuperAdmin(): bool
  311.     {
  312.         return $this->hasRole(UserRoleEnum::ROLE_SUPER_ADMIN->value);
  313.     }
  314.     /**
  315.      * @param bool $enabled
  316.      */
  317.     public function setEnabled(bool $enabled): void
  318.     {
  319.         $this->enabled $enabled;
  320.     }
  321.     /**
  322.      * @return string|null
  323.      */
  324.     public function getSalt(): ?string
  325.     {
  326.         return $this->salt;
  327.     }
  328.     /**
  329.      * @param string|null $salt
  330.      */
  331.     public function setSalt(?string $salt): void
  332.     {
  333.         $this->salt $salt;
  334.     }
  335.     /**
  336.      * @return string
  337.      */
  338.     public function getPassword(): string
  339.     {
  340.         return $this->password;
  341.     }
  342.     /**
  343.      * @param string $password
  344.      */
  345.     public function setPassword(string $password): void
  346.     {
  347.         $this->password $password;
  348.     }
  349.     /**
  350.      * @return DateTime|null
  351.      */
  352.     public function getLastLogin(): ?DateTime
  353.     {
  354.         return $this->lastLogin;
  355.     }
  356.     /**
  357.      * @param DateTime|null $lastLogin
  358.      */
  359.     public function setLastLogin(?DateTime $lastLogin): void
  360.     {
  361.         $this->lastLogin $lastLogin;
  362.     }
  363.     /**
  364.      * @return string|null
  365.      */
  366.     public function getConfirmationToken(): ?string
  367.     {
  368.         return $this->confirmationToken;
  369.     }
  370.     /**
  371.      * @param string|null $confirmationToken
  372.      */
  373.     public function setConfirmationToken(?string $confirmationToken): void
  374.     {
  375.         $this->confirmationToken $confirmationToken;
  376.     }
  377.     /**
  378.      * @return DateTime|null
  379.      */
  380.     public function getPasswordRequestedAt(): ?DateTime
  381.     {
  382.         return $this->passwordRequestedAt;
  383.     }
  384.     /**
  385.      * @param DateTime|null $passwordRequestedAt
  386.      */
  387.     public function setPasswordRequestedAt(?DateTime $passwordRequestedAt): void
  388.     {
  389.         $this->passwordRequestedAt $passwordRequestedAt;
  390.     }
  391.     /**
  392.      * @return string[]
  393.      */
  394.     public function getRoles(): array
  395.     {
  396.         $roles $this->roles;
  397.         // we need to make sure to have at least one role
  398.         $roles[] = UserRoleEnum::ROLE_DEFAULT->value;
  399.         return array_unique($roles);
  400.     }
  401.     /**
  402.      * @param string $role
  403.      * @return bool
  404.      */
  405.     #[Ignore]
  406.     public function hasRole(string $role): bool
  407.     {
  408.         return in_array(strtoupper($role), $this->getRoles(), true);
  409.     }
  410.     /**
  411.      * @param string[] $roles
  412.      * @return $this
  413.      */
  414.     public function setRoles(array $roles): self
  415.     {
  416.         $this->roles = array();
  417.         foreach ($roles as $role) {
  418.             $this->addRole($role);
  419.         }
  420.         return $this;
  421.     }
  422.     /**
  423.      * @param int $ttl
  424.      * @return bool
  425.      */
  426.     #[Ignore]
  427.     public function isPasswordRequestNonExpired(int $ttl): bool
  428.     {
  429.         return $this->getPasswordRequestedAt() instanceof \DateTime &&
  430.             $this->getPasswordRequestedAt()->getTimestamp() + $ttl time();
  431.     }
  432.     /**
  433.      * @return string|null
  434.      */
  435.     public function getPlainPassword(): ?string
  436.     {
  437.         return $this->plainPassword;
  438.     }
  439.     /**
  440.      * @param string|null $plainPassword
  441.      */
  442.     public function setPlainPassword(?string $plainPassword): void
  443.     {
  444.         $this->plainPassword $plainPassword;
  445.     }
  446.     /**
  447.      * @return string|null
  448.      */
  449.     public function getFirstname(): ?string
  450.     {
  451.         return $this->firstname;
  452.     }
  453.     /**
  454.      * @param string|null $firstname
  455.      */
  456.     public function setFirstname(?string $firstname): void
  457.     {
  458.         $this->firstname $firstname;
  459.     }
  460.     /**
  461.      * @return string|null
  462.      */
  463.     public function getLastname(): ?string
  464.     {
  465.         return $this->lastname;
  466.     }
  467.     /**
  468.      * @param string|null $lastname
  469.      */
  470.     public function setLastname(?string $lastname): void
  471.     {
  472.         $this->lastname $lastname;
  473.     }
  474.     /**
  475.      * @return bool
  476.      */
  477.     public function getHasAcceptedTerms(): bool
  478.     {
  479.         return $this->hasAcceptedTerms;
  480.     }
  481.     /**
  482.      * @param bool $hasAcceptedTerms
  483.      */
  484.     public function setHasAcceptedTerms(bool $hasAcceptedTerms): void
  485.     {
  486.         $this->hasAcceptedTerms $hasAcceptedTerms;
  487.     }
  488.     /**
  489.      * @return string|null
  490.      */
  491.     public function getAddress(): ?string
  492.     {
  493.         return $this->address;
  494.     }
  495.     /**
  496.      * @param string|null $address
  497.      */
  498.     public function setAddress(?string $address): void
  499.     {
  500.         $this->address $address;
  501.     }
  502.     /**
  503.      * @return string|null
  504.      */
  505.     public function getStreetnumber(): ?string
  506.     {
  507.         return $this->streetNumber;
  508.     }
  509.     /**
  510.      * @param string|null $streetNumber
  511.      */
  512.     public function setStreetNumber(?string $streetNumber): void
  513.     {
  514.         $this->streetNumber $streetNumber;
  515.     }
  516.     /**
  517.      * @return string|null
  518.      */
  519.     public function getZip(): ?string
  520.     {
  521.         return $this->zip;
  522.     }
  523.     /**
  524.      * @param string|null $zip
  525.      */
  526.     public function setZip(?string $zip): void
  527.     {
  528.         $this->zip $zip;
  529.     }
  530.     /**
  531.      * @return string|null
  532.      */
  533.     public function getCity(): ?string
  534.     {
  535.         return $this->city;
  536.     }
  537.     /**
  538.      * @param string|null $city
  539.      */
  540.     public function setCity(?string $city): void
  541.     {
  542.         $this->city $city;
  543.     }
  544.     /**
  545.      * @return string|null
  546.      */
  547.     public function getPhoneNumber(): ?string
  548.     {
  549.         return $this->phoneNumber;
  550.     }
  551.     /**
  552.      * @param string|null $phoneNumber
  553.      */
  554.     public function setPhoneNumber(?string $phoneNumber): void
  555.     {
  556.         $this->phoneNumber $phoneNumber;
  557.     }
  558.     /**
  559.      * @return string|null
  560.      */
  561.     public function getCompanyName(): ?string
  562.     {
  563.         return $this->companyName;
  564.     }
  565.     /**
  566.      * @param string|null $companyName
  567.      */
  568.     public function setCompanyName(?string $companyName): void
  569.     {
  570.         $this->companyName $companyName;
  571.     }
  572.     /**
  573.      * @return DateTime|null
  574.      */
  575.     public function getCreatedAt(): ?DateTime
  576.     {
  577.         return $this->createdAt;
  578.     }
  579.     /**
  580.      * @param DateTime $createdAt
  581.      */
  582.     public function setCreatedAt(DateTime $createdAt): void
  583.     {
  584.         $this->createdAt $createdAt;
  585.     }
  586.     /**
  587.      * @return DateTime
  588.      */
  589.     public function getUpdatedAt(): DateTime
  590.     {
  591.         return $this->updatedAt;
  592.     }
  593.     /**
  594.      * @param DateTime $updatedAt
  595.      */
  596.     public function setUpdatedAt(DateTime $updatedAt): void
  597.     {
  598.         $this->updatedAt $updatedAt;
  599.     }
  600.     /**
  601.      * @ORM\PrePersist
  602.      */
  603.     public function incrementCreatedAt(): void
  604.     {
  605.         if ($this->createdAt === null) {
  606.             $this->createdAt = new DateTime();
  607.         }
  608.         $this->updatedAt = new DateTime();
  609.     }
  610.     /**
  611.      * @ORM\PreUpdate
  612.      */
  613.     public function incrementUpdatedAt(): void
  614.     {
  615.         $this->updatedAt = new DateTime();
  616.     }
  617.     /**
  618.      * @return string|null
  619.      */
  620.     public function getMatId(): ?string
  621.     {
  622.         return $this->matId;
  623.     }
  624.     /**
  625.      * @param string|null $matId
  626.      */
  627.     public function setMatId(?string $matId): void
  628.     {
  629.         $this->matId $matId;
  630.     }
  631.     /**
  632.      * @return string|null
  633.      */
  634.     public function getPib(): ?string
  635.     {
  636.         return $this->pib;
  637.     }
  638.     /**
  639.      * @param string|null $pib
  640.      */
  641.     public function setPib(?string $pib): void
  642.     {
  643.         $this->pib $pib;
  644.     }
  645.     /**
  646.      * @return string|null
  647.      */
  648.     public function getCompanyTitle(): ?string
  649.     {
  650.         return $this->companyTitle;
  651.     }
  652.     /**
  653.      * @param string|null $companyTitle
  654.      */
  655.     public function setCompanyTitle(?string $companyTitle): void
  656.     {
  657.         $this->companyTitle $companyTitle;
  658.     }
  659.     /**
  660.      * @return string|null
  661.      */
  662.     public function getLicenseId(): ?string
  663.     {
  664.         return $this->licenseId;
  665.     }
  666.     /**
  667.      * @param string|null $licenseId
  668.      */
  669.     public function setLicenseId(?string $licenseId): void
  670.     {
  671.         $this->licenseId $licenseId;
  672.     }
  673.     /**
  674.      * @return string|null
  675.      */
  676.     public function getBankAccount(): ?string
  677.     {
  678.         return $this->bankAccount;
  679.     }
  680.     /**
  681.      * @param string|null $bankAccount
  682.      */
  683.     public function setBankAccount(?string $bankAccount): void
  684.     {
  685.         $this->bankAccount $bankAccount;
  686.     }
  687.     /**
  688.      * @return bool
  689.      */
  690.     public function getEnableQr(): bool
  691.     {
  692.         return $this->enableQr;
  693.     }
  694.     /**
  695.      * @param bool $enableQr
  696.      */
  697.     public function setEnableQr(bool $enableQr): void
  698.     {
  699.         $this->enableQr $enableQr;
  700.     }
  701.     /**
  702.      * @return Collection<int, Obligation>
  703.      */
  704.     #[Ignore]
  705.     public function getObligations(): Collection
  706.     {
  707.         return $this->obligations;
  708.     }
  709.     /**
  710.      * @param Obligation $obligation
  711.      * @return $this
  712.      */
  713.     public function addObligation(Obligation $obligation): self
  714.     {
  715.         if (!$this->obligations->contains($obligation)) {
  716.             $this->obligations[] = $obligation;
  717.             $obligation->setUser($this);
  718.         }
  719.         return $this;
  720.     }
  721.     /**
  722.      * @param Obligation $obligation
  723.      * @return $this
  724.      */
  725.     public function removeObligation(Obligation $obligation): self
  726.     {
  727.         if ($this->obligations->contains($obligation)) {
  728.             $this->obligations->removeElement($obligation);
  729.             if ($obligation->getUser() === $this) {
  730.                 $obligation->setUser(null);
  731.             }
  732.         }
  733.         return $this;
  734.     }
  735.     /**
  736.      * @return string|null
  737.      */
  738.     public function getTaskNotificationEmail(): ?string
  739.     {
  740.         return $this->taskNotificationEmail;
  741.     }
  742.     /**
  743.      * @param string|null $taskNotificationEmail
  744.      */
  745.     public function setTaskNotificationEmail(?string $taskNotificationEmail): void
  746.     {
  747.         $this->taskNotificationEmail $taskNotificationEmail;
  748.     }
  749.     /**
  750.      * @return User|null
  751.      */
  752.     #[Ignore]
  753.     public function getMainUser(): ?User
  754.     {
  755.         return $this->mainUser;
  756.     }
  757.     /**
  758.      * @param User|null $mainUser
  759.      */
  760.     #[Ignore]
  761.     public function setMainUser(?User $mainUser): void
  762.     {
  763.         $this->mainUser $mainUser;
  764.     }
  765.     /**
  766.      * Returns company role or null
  767.      * @return string|null
  768.      */
  769.     public function getCompanyRole(): ?string
  770.     {
  771.         foreach ($this->getRoles() as $role) {
  772.             if (in_array($roleCompanyRoleEnum::getAllValues(), true)) {
  773.                 return $role;
  774.             }
  775.         }
  776.         return null;
  777.     }
  778.     /**
  779.      * Returns property which is used for createdBy fields of other tables
  780.      *
  781.      * @return string
  782.      */
  783.     public function getCreatedByValue(): string
  784.     {
  785.         return sprintf('%s.%s.'mb_substr($this->getFirstname(), 01), mb_substr($this->getLastname(), 01));
  786.     }
  787.     /**
  788.      * @return User
  789.      */
  790.     #[Ignore]
  791.     public function getSharedCompanyUser(): User
  792.     {
  793.         return $this->mainUser !== null $this->mainUser $this;
  794.     }
  795.     /**
  796.      * @return array<User>
  797.      */
  798.     public function getUserAndMainUser(): array
  799.     {
  800.         $users = [];
  801.         $users[] = $this;
  802.         if ($this->mainUser) {
  803.             $users[] = $this->mainUser;
  804.         }
  805.         return $users;
  806.     }
  807.     /**
  808.      * @param string $role
  809.      * @return $this
  810.      */
  811.     public function addRole(string $role): self
  812.     {
  813.         $role strtoupper($role);
  814.         if ($role === UserRoleEnum::ROLE_DEFAULT->value) {
  815.             return $this;
  816.         }
  817.         if (!in_array($role$this->rolestrue)) {
  818.             if (in_array($roleCompanyRoleEnum::getAllValues(), true)) {
  819.                 foreach (CompanyRoleEnum::getAllValues() as $companyRole) {
  820.                     $this->removeRole($companyRole);
  821.                 }
  822.             }
  823.             $this->roles[] = $role;
  824.         }
  825.         return $this;
  826.     }
  827.     /**
  828.      * @param string $role
  829.      * @return $this
  830.      */
  831.     public function removeRole(string $role): self
  832.     {
  833.         if (false !== $key array_search(strtoupper($role), $this->rolestrue)) {
  834.             unset($this->roles[$key]);
  835.             $this->roles array_values($this->roles);
  836.         }
  837.         return $this;
  838.     }
  839.     /**
  840.      * @return string
  841.      */
  842.     public function getFullName(): string
  843.     {
  844.         return sprintf('%s %s'$this->getFirstname(), $this->getLastname());
  845.     }
  846.     /**
  847.      * @return Collection<int, ActionLog>
  848.      */
  849.     #[Ignore]
  850.     public function getActionLogs(): Collection
  851.     {
  852.         return $this->actionLogs;
  853.     }
  854.     /**
  855.      * @param ActionLog $actionLog
  856.      * @return $this
  857.      */
  858.     public function addActionLog(ActionLog $actionLog): self
  859.     {
  860.         if (!$this->actionLogs->contains($actionLog)) {
  861.             $this->actionLogs[] = $actionLog;
  862.             $actionLog->setUser($this);
  863.         }
  864.         return $this;
  865.     }
  866.     /**
  867.      * @param ActionLog $actionLog
  868.      * @return $this
  869.      */
  870.     public function removeActionLog(ActionLog $actionLog): self
  871.     {
  872.         if ($this->actionLogs->removeElement($actionLog)) {
  873.             // set the owning side to null (unless already changed)
  874.             if ($actionLog->getUser() === $this) {
  875.                 $actionLog->setUser(null);
  876.             }
  877.         }
  878.         return $this;
  879.     }
  880.     /**
  881.      * @return string
  882.      */
  883.     public function __toString(): string
  884.     {
  885.         return (string) $this->getUsername();
  886.     }
  887.     //
  888.     //    /**
  889.     //     * @return string
  890.     //     */
  891.     //    public function serialize(): string
  892.     //    {
  893.     //        return serialize(array(
  894.     //            $this->password,
  895.     //            $this->getSalt(),
  896.     //            $this->usernameCanonical,
  897.     //            $this->username,
  898.     //            $this->enabled,
  899.     //            $this->id,
  900.     //            $this->email,
  901.     //            $this->emailCanonical,
  902.     //        ));
  903.     //    }
  904.     //
  905.     //    /**
  906.     //     * @param string $serialized
  907.     //     */
  908.     //    public function unserialize($serialized): void
  909.     //    {
  910.     //        $data = unserialize($serialized);
  911.     //
  912.     //        if (13 === count($data)) {
  913.     //            // Unserializing a User object from 1.3.x
  914.     //            unset($data[4], $data[5], $data[6], $data[9], $data[10]);
  915.     //            $data = array_values($data);
  916.     //        } elseif (11 === count($data)) {
  917.     //            // Unserializing a User from a dev version somewhere between 2.0-alpha3 and 2.0-beta1
  918.     //            unset($data[4], $data[7], $data[8]);
  919.     //            $data = array_values($data);
  920.     //        }
  921.     //
  922.     //        list(
  923.     //            $this->password,
  924.     //            $this->salt,
  925.     //            $this->usernameCanonical,
  926.     //            $this->username,
  927.     //            $this->enabled,
  928.     //            $this->id,
  929.     //            $this->email,
  930.     //            $this->emailCanonical
  931.     //            ) = $data;
  932.     //    }
  933.     public function eraseCredentials(): void
  934.     {
  935.         $this->setPlainPassword(null);
  936.     }
  937.     /**
  938.      * @param bool $boolean
  939.      * @return $this
  940.      */
  941.     public function setSuperAdmin(bool $boolean): self
  942.     {
  943.         if ($boolean === true) {
  944.             $this->addRole(UserRoleEnum::ROLE_SUPER_ADMIN->value);
  945.         } else {
  946.             $this->removeRole(UserRoleEnum::ROLE_SUPER_ADMIN->value);
  947.         }
  948.         return $this;
  949.     }
  950.     /**
  951.      * @return string
  952.      */
  953.     public function getUserIdentifier(): string
  954.     {
  955.         return $this->getUsername();
  956.     }
  957.     /**
  958.      * @return bool
  959.      */
  960.     public function isUserCyrillic(): bool
  961.     {
  962.         $userArray = ['draganaDjordjevic'];
  963.         if (in_array($this->getCompanyName(), $userArray)) {
  964.             return true;
  965.         }
  966.         return false;
  967.     }
  968.     /**
  969.      * @return string
  970.      */
  971.     public function getCurrency(): string
  972.     {
  973.         return $this->currency;
  974.     }
  975.     /**
  976.      * @return int
  977.      */
  978.     public function getPaidBill(): int
  979.     {
  980.         return $this->paidBill;
  981.     }
  982.     /**
  983.      * @param int $paidBill
  984.      */
  985.     public function setPaidBill(int $paidBill): void
  986.     {
  987.         $this->paidBill $paidBill;
  988.     }
  989. }