src/Entity/Accounts/Users.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Accounts;
  3. use App\Repository\Accounts\UsersRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. /**
  10.  * tUsers
  11.  *
  12.  * @ORM\Entity(repositoryClass="App\Repository\Accounts\UsersRepository")
  13.  * @ORM\Table(name="otp_accounts.tUsers", uniqueConstraints={@ORM\UniqueConstraint(name="fMail", columns={"fMail"}), @ORM\UniqueConstraint(name="fLogin", columns={"fLogin"})}, indexes={@ORM\Index(name="fSource", columns={"fSource", "fActive"}), @ORM\Index(name="fSubscribePausedTo", columns={"fSubscribePausedTo"}), @ORM\Index(name="fMaildeActivated", columns={"fMaildeActivated_delete"}), @ORM\Index(name="sub", columns={"fSubscribeMode_delete", "fSubscribePromo_delete", "fSource"}), @ORM\Index(name="fMailVerify", columns={"fMailVerify"}), @ORM\Index(name="fCountry", columns={"fCountry"}), @ORM\Index(name="fPhone", columns={"fPhone"}), @ORM\Index(name="fAutoReject", columns={"fAutoReject"}), @ORM\Index(name="fIp", columns={"fIp"}), @ORM\Index(name="fName", columns={"fName"}), @ORM\Index(name="fRegDate", columns={"fRegDate"}), @ORM\Index(name="fActive", columns={"fActive", "fReject_delete"})})
  14.  */
  15. class Users implements UserInterface
  16. {
  17.     /**
  18.      * @var int
  19.      *
  20.      * @ORM\Column(name="rec_id", type="integer", nullable=false, options={"unsigned"=true})
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue(strategy="IDENTITY")
  23.      */
  24.     private $id;
  25.     public function __construct()
  26.     {
  27.         $this->regDate = new \DateTime();
  28.         $this->recoveries = new ArrayCollection();
  29.         $this->userFavorites = new ArrayCollection();
  30.     }
  31.     /**
  32.      * @ORM\OneToMany(targetEntity="App\Entity\Accounts\UserTokens", mappedBy="user", cascade={"persist", "remove"})
  33.      */
  34.     private $tokens;
  35.     /**
  36.      * @ORM\OneToMany(targetEntity="App\Entity\Accounts\UserRecovery", mappedBy="user", cascade={"persist", "remove"})
  37.      */
  38.     private $recoveries;
  39.     /**
  40.      * @return Collection|UserRecovery[]
  41.      */
  42.     public function getRecoveries(): Collection
  43.     {
  44.         return $this->recoveries;
  45.     }
  46.     public function addRecovery(UserRecovery $recovery): static
  47.     {
  48.         if (!$this->recoveries->contains($recovery)) {
  49.             $this->recoveries[] = $recovery;
  50.             $recovery->setUser($this);
  51.         }
  52.         return $this;
  53.     }
  54.     public function removeRecovery(UserRecovery $recovery): static
  55.     {
  56.         if ($this->recoveries->removeElement($recovery)) {
  57.             // Установлюємо null у властивості user, щоб уникнути циклічної залежності
  58.             if ($recovery->getUser() === $this) {
  59.                 $recovery->setUser(null);
  60.             }
  61.         }
  62.         return $this;
  63.     }
  64.     /**
  65.      * @ORM\OneToMany(targetEntity="UserFavorite", mappedBy="user", cascade={"persist", "remove"})
  66.      */
  67.     private Collection $userFavorites;
  68.     public function getUserFavorites(): Collection
  69.     {
  70.         return $this->userFavorites;
  71.     }
  72.     public function addUserFavorite(UserFavorite $userFavorite): self
  73.     {
  74.         if (!$this->userFavorites->contains($userFavorite)) {
  75.             $this->userFavorites[] = $userFavorite;
  76.             $userFavorite->setUser($this);
  77.         }
  78.         return $this;
  79.     }
  80.     public function removeUserFavorite(UserFavorite $userFavorite): self
  81.     {
  82.         if ($this->userFavorites->removeElement($userFavorite)) {
  83.             if ($userFavorite->getUser() === $this) {
  84.                 $userFavorite->setUser(null);
  85.             }
  86.         }
  87.         return $this;
  88.     }
  89.     /**
  90.      * @var string
  91.      *
  92.      * @ORM\Column(name="fLogin", type="string", length=50, nullable=false, options={"comment"="логин пользователя"})
  93.      */
  94.     private $login;
  95.     /**
  96.      * @var string
  97.      *
  98.      * @ORM\Column(name="fPasswordHash", type="string", length=255, nullable=false, options={"fixed"=true})
  99.      */
  100.     private $passwordHash;
  101.     /**
  102.      * @var string
  103.      *
  104.      * @ORM\Column(name="fName", type="string", length=64, nullable=false)
  105.      */
  106.     private $name;
  107.     /**
  108.      * @var \DateTime|null
  109.      *
  110.      * @ORM\Column(name="fBirthDay", type="date", nullable=true)
  111.      */
  112.     private ?\DateTimeInterface $birthDay null;
  113.     /**
  114.      * @var string|null
  115.      *
  116.      * @ORM\Column(name="fSex", type="string", length=0, nullable=true)
  117.      */
  118.     private $sex;
  119.     /**
  120.      * @var int|null
  121.      *
  122.      * @ORM\Column(name="fCountry", type="integer", nullable=true, options={"default"="3550","unsigned"=true})
  123.      */
  124.     private $country 3550;
  125.     /**
  126.      * @var int|null
  127.      *
  128.      * @ORM\Column(name="fCity", type="integer", nullable=true, options={"unsigned"=true})
  129.      */
  130.     private $city;
  131.     /**
  132.      * @var string|null
  133.      *
  134.      * @ORM\Column(name="fText", type="text", length=65535, nullable=true)
  135.      */
  136.     private $text;
  137.     /**
  138.      * @var string
  139.      *
  140.      * @ORM\Column(name="fUrl", type="string", length=255, nullable=false)
  141.      */
  142.     private $url '';
  143.     /**
  144.      * @var string
  145.      *
  146.      * @ORM\Column(name="fImage", type="string", length=32, nullable=false)
  147.      */
  148.     private $image '';
  149.     /**
  150.      * @var string
  151.      *
  152.      * @ORM\Column(name="fImageSize", type="string", length=12, nullable=false, options={"comment"="Размер (w,h)"})
  153.      */
  154.     private $imageSize '';
  155.     /**
  156.      * @var int
  157.      *
  158.      * @ORM\Column(name="fIp", type="bigint", nullable=false)
  159.      */
  160.     private $ip;
  161.     /**
  162.      * @var int
  163.      *
  164.      * @ORM\Column(name="fRealIp", type="bigint", nullable=false, options={"comment"="не исп"})
  165.      */
  166.     private $realIp '';
  167.     /**
  168.      * @var string|null
  169.      *
  170.      * @ORM\Column(name="fMail", type="string", length=80, nullable=true)
  171.      */
  172.     private $mail;
  173.     /**
  174.      * @var string|null
  175.      *
  176.      * @ORM\Column(name="fPhone", type="string", length=64, nullable=true, options={"comment"="Номер телефона"})
  177.      */
  178.     private $phone;
  179.     /**
  180.      * @var string|null
  181.      *
  182.      * @ORM\Column(name="fPhoneSMS", type="string", length=6, nullable=true, options={"comment"="перевірка через СМС"})
  183.      */
  184.     private $phoneSms;
  185.     /**
  186.      * @var string|null
  187.      *
  188.      * @ORM\Column(name="fPhone2", type="string", length=16, nullable=true, options={"comment"="Номер телефона"})
  189.      */
  190.     private $phoneAdd;
  191.     /**
  192.      * @var string|null
  193.      *
  194.      * @ORM\Column(name="fPhone2SMS", type="string", length=6, nullable=true, options={"comment"="перевірка через СМС"})
  195.      */
  196.     private $phoneAddSms;
  197.     /**
  198.      * @var string
  199.      *
  200.      * @ORM\Column(name="fMailVerify", type="string", length=0, nullable=false, options={"default"="no","comment"="активация"})
  201.      */
  202.     private $mailVerify 'no';
  203.     /**
  204.      * @var string
  205.      *
  206.      * @ORM\Column(name="fMailMode", type="string", length=0, nullable=false, options={"default"="invisible","comment"="статус для форума"})
  207.      */
  208.     private $mailMode 'invisible';
  209.     /**
  210.      * @var \DateTime
  211.      *
  212.      * @ORM\Column(name="fRegDate", type="datetime", nullable=false, options={"default"="CURRENT_TIMESTAMP"})
  213.      */
  214.     private $regDate 'CURRENT_TIMESTAMP';
  215.     /**
  216.      * @var \DateTime|null
  217.      *
  218.      * @ORM\Column(name="fLastUpdate", type="datetime", nullable=true, options={"comment"="дата последней правки"})
  219.      */
  220.     private $lastUpdate;
  221.     /**
  222.      * @var \DateTime|null
  223.      *
  224.      * @ORM\Column(name="fLoginDate", type="datetime", nullable=true)
  225.      */
  226.     private $loginDate;
  227.     /**
  228.      * @var string|null
  229.      *
  230.      * @ORM\Column(name="fSource", type="string", length=0, nullable=true, options={"comment"="от куда регистрация"})
  231.      */
  232.     private $source 'otpusk';
  233.     /**
  234.      * @var float
  235.      *
  236.      * @ORM\Column(name="fRating", type="float", precision=10, scale=1, nullable=false, options={"default"="0.0"})
  237.      */
  238.     private $rating 5;
  239.     /**
  240.      * @var string
  241.      *
  242.      * @ORM\Column(name="fActive", type="string", length=0, nullable=false, options={"default"="yes","comment"="выключен аккаунт или нет"})
  243.      */
  244.     private $active 'yes';
  245.     /**
  246.      * @var string
  247.      *
  248.      * @ORM\Column(name="fSocialNotice", type="string", length=0, nullable=false, options={"default"="add_in_friends,new_messages","comment"="о чем отсылать уведомления из соцсети"})
  249.      */
  250.     private $socialNotice 'add_in_friends,new_messages';
  251.     /**
  252.      * @var \DateTime|null
  253.      *
  254.      * @ORM\Column(name="fAutoReject", type="datetime", nullable=true, options={"comment"="Отписка при разборе возвратов"})
  255.      */
  256.     private $autoReject;
  257.     
  258.     // ----------------
  259.     /**
  260.      * @var \DateTime|null
  261.      *
  262.      * @ORM\Column(name="fSubscribePausedTo", type="date", nullable=true, options={"comment"="Пауза рассылки до"})
  263.      */
  264.     private $subscribePausedTo;
  265.     /**
  266.      * @var string|null
  267.      *
  268.      * @ORM\Column(name="fSubscribePausedReason", type="string", length=255, nullable=true, options={"comment"="Причина паузы рассылки"})
  269.      */
  270.     private $subscribePausedReason;
  271.     /**
  272.      * @var string
  273.      *
  274.      * @ORM\Column(name="fSubscribeMode_delete", type="string", length=0, nullable=false, options={"default"="my","comment"="удалить, не используется"})
  275.      */
  276.     private $subscribeModeDelete 'my';
  277.     /**
  278.      * @var string
  279.      *
  280.      * @ORM\Column(name="fSubscribePromo_delete", type="string", length=0, nullable=false, options={"default"="otpusk,turpravda,mandria"})
  281.      */
  282.     private $subscribePromoDelete 'otpusk,turpravda,mandria';
  283.     /**
  284.      * @var \DateTime|null
  285.      *
  286.      * @ORM\Column(name="fSubscribeSent_delete", type="datetime", nullable=true, options={"comment"="Последняя отправка"})
  287.      */
  288.     private $subscribeSentDelete;
  289.     /**
  290.      * @var \DateTime|null
  291.      *
  292.      * @ORM\Column(name="fSubscribeReaded_delete", type="datetime", nullable=true, options={"comment"="Последнее прочтение"})
  293.      */
  294.     private $subscribeReadedDelete;
  295.     /**
  296.      * @var \DateTime|null
  297.      *
  298.      * @ORM\Column(name="fSubscribeJumped_delete", type="datetime", nullable=true, options={"comment"="Последний переход"})
  299.      */
  300.     private $subscribeJumpedDelete;
  301.     /**
  302.      * @var \DateTime|null
  303.      *
  304.      * @ORM\Column(name="fSubscribeRejected_delete", type="datetime", nullable=true, options={"comment"="Отписка пользователем"})
  305.      */
  306.     private $subscribeRejectedDelete;
  307.     /**
  308.      * @var \DateTime|null
  309.      *
  310.      * @ORM\Column(name="fSubscribeReturned_delete", type="datetime", nullable=true, options={"comment"="Последний возврат"})
  311.      */
  312.     private $subscribeReturnedDelete;
  313.     /**
  314.      * @var bool
  315.      *
  316.      * @ORM\Column(name="fLevel_delete", type="boolean", nullable=false, options={"default"="1","comment"="удалить, поле использовалось для модерации форума"})
  317.      */
  318.     private $levelDelete true;
  319.     /**
  320.      * @var bool|null
  321.      *
  322.      * @ORM\Column(name="fReject_delete", type="boolean", nullable=true, options={"comment"="Фатальная отписка, автоматическая или вручную"})
  323.      */
  324.     private $rejectDelete '0';
  325.     /**
  326.      * @var \DateTime|null
  327.      *
  328.      * @ORM\Column(name="fMaildeActivated_delete", type="datetime", nullable=true, options={"comment"="Дата отписки из крона по возврату"})
  329.      */
  330.     private $maildeActivatedDelete;
  331.     public function getRoles(): array
  332.     {
  333.         return ['ROLE_USER'];
  334.     }
  335.     public function getSalt(): ?string
  336.     {
  337.         return null;
  338.     }
  339.     public function eraseCredentials(): void
  340.     {
  341.     }
  342.     public function getUserIdentifier(): string
  343.     {
  344.         return $this->login;
  345.     }
  346.     public function getUsername(): string
  347.     {
  348.         return $this->name;
  349.     }
  350.     public function getPassword(): ?string
  351.     {
  352.         return $this->passwordHash;
  353.     }
  354.     public function setPassword(string $passwordHash): static
  355.     {
  356.         $this->passwordHash $passwordHash;
  357.         return $this;
  358.     }
  359.     // ==================
  360.     public function getId(): ?int
  361.     {
  362.         return $this->id;
  363.     }
  364.     public function getLogin(): ?string
  365.     {
  366.         return $this->login;
  367.     }
  368.     public function setLogin(string $login): static
  369.     {
  370.         $this->login $login;
  371.         return $this;
  372.     }
  373.     public function getPasswordHash(): ?string
  374.     {
  375.         return $this->passwordHash;
  376.     }
  377.     public function setPasswordHash(string $passwordHash): static
  378.     {
  379.         $this->passwordHash $passwordHash;
  380.         return $this;
  381.     }
  382.     public function getName(): ?string
  383.     {
  384.         return $this->name;
  385.     }
  386.     public function setName(string $name): static
  387.     {
  388.         $this->name $name;
  389.         return $this;
  390.     }
  391.     public function getBirthDay(): ?\DateTimeInterface
  392.     {
  393.         return $this->birthDay;
  394.     }
  395.     public function setBirthDay(?\DateTimeInterface $birthDay): static
  396.     {
  397.         $this->birthDay $birthDay;
  398.         return $this;
  399.     }
  400.     public function getSex(): ?string
  401.     {
  402.         return $this->sex;
  403.     }
  404.     public function setSex(?string $sex): static
  405.     {
  406.         $this->sex $sex;
  407.         return $this;
  408.     }
  409.     public function getCountry(): ?int
  410.     {
  411.         return $this->country;
  412.     }
  413.     public function setCountry(?int $country): static
  414.     {
  415.         $this->country $country;
  416.         return $this;
  417.     }
  418.     public function getCity(): ?int
  419.     {
  420.         return $this->city;
  421.     }
  422.     public function setCity(?int $city): static
  423.     {
  424.         $this->city $city;
  425.         return $this;
  426.     }
  427.     public function getText(): ?string
  428.     {
  429.         return $this->text;
  430.     }
  431.     public function setText(?string $text): static
  432.     {
  433.         $this->text $text;
  434.         return $this;
  435.     }
  436.     public function getUrl(): ?string
  437.     {
  438.         return $this->url;
  439.     }
  440.     public function setUrl(string $url): static
  441.     {
  442.         $this->url $url;
  443.         return $this;
  444.     }
  445.     public function getImage(): ?string
  446.     {
  447.         return $this->image;
  448.     }
  449.     public function getImageAvatar()
  450.     {
  451.         $h dechex($this->id);
  452.         $l strrev(wordwrap(strrev($h), 2'|'1));
  453.         $l array_reverse(explode('|'$l));
  454.         if (empty($l[0])) $l[0] = 0;
  455.         if (empty($l[1])) $l[1] = 0;
  456.         if (empty($l[2])) $l[2] = 0;
  457.         if (empty($l[3])) $l[3] = 0;
  458.         return sprintf("%02s/%02s/%02s/%02s/"$l[3], $l[2], $l[1], $l[0]) . $this->id '.jpg';
  459.     }
  460.     public function setImage(string $image): static
  461.     {
  462.         $this->image $image;
  463.         return $this;
  464.     }
  465.     public function getImageSize(): ?string
  466.     {
  467.         return $this->imageSize;
  468.     }
  469.     public function setImageSize(string $imageSize): static
  470.     {
  471.         $this->imageSize $imageSize;
  472.         return $this;
  473.     }
  474.     public function getIp(): ?string
  475.     {
  476.         return $this->ip;
  477.     }
  478.     public function setIp(string $ip): static
  479.     {
  480.         $this->ip $ip;
  481.         return $this;
  482.     }
  483.     public function getRealIp(): ?string
  484.     {
  485.         return $this->realIp;
  486.     }
  487.     public function setRealIp(string $realIp): static
  488.     {
  489.         $this->realIp $realIp;
  490.         return $this;
  491.     }
  492.     public function getMail(): ?string
  493.     {
  494.         return $this->mail;
  495.     }
  496.     public function setMail(?string $mail): static
  497.     {
  498.         $this->mail $mail;
  499.         return $this;
  500.     }
  501.     public function getEmail(): ?string
  502.     {
  503.         return $this->mail;
  504.     }
  505.     public function setEmail(?string $mail): static
  506.     {
  507.         $this->mail $mail;
  508.         return $this;
  509.     }
  510.     public function getPhone(): ?string
  511.     {
  512.         return $this->phone;
  513.     }
  514.     public function setPhone(?string $phone): static
  515.     {
  516.         $this->phone $phone;
  517.         return $this;
  518.     }
  519.     public function getPhoneSms(): ?string
  520.     {
  521.         return $this->phoneSms;
  522.     }
  523.     public function setPhoneSms(?string $phone): static
  524.     {
  525.         $this->phoneSms $phone;
  526.         return $this;
  527.     }
  528.     public function getPhoneAdd(): ?string
  529.     {
  530.         return $this->phoneAdd;
  531.     }
  532.     public function setPhoneAdd(?string $phone): static
  533.     {
  534.         $this->phoneAdd $phone;
  535.         return $this;
  536.     }
  537.     public function getPhoneAddSms(): ?string
  538.     {
  539.         return $this->phoneAddSms;
  540.     }
  541.     public function setPhoneAddSms(?string $phone): static
  542.     {
  543.         $this->phoneAddSms $phone;
  544.         return $this;
  545.     }
  546.     public function getMailVerify(): ?string
  547.     {
  548.         return $this->mailVerify;
  549.     }
  550.     public function setMailVerify(string $mailVerify): static
  551.     {
  552.         $this->mailVerify $mailVerify;
  553.         return $this;
  554.     }
  555.     public function getMailMode(): ?string
  556.     {
  557.         return $this->mailMode;
  558.     }
  559.     public function setMailMode(string $mailMode): static
  560.     {
  561.         $this->mailMode $mailMode;
  562.         return $this;
  563.     }
  564.     public function getRegDate(): ?\DateTimeInterface
  565.     {
  566.         return $this->regDate;
  567.     }
  568.     public function setRegDate(\DateTimeInterface $regDate): static
  569.     {
  570.         $this->regDate $regDate;
  571.         return $this;
  572.     }
  573.     public function getLastUpdate(): ?\DateTimeInterface
  574.     {
  575.         return $this->lastUpdate;
  576.     }
  577.     public function setLastUpdate(?\DateTimeInterface $lastUpdate): static
  578.     {
  579.         $this->lastUpdate $lastUpdate;
  580.         return $this;
  581.     }
  582.     public function getLoginDate(): ?\DateTimeInterface
  583.     {
  584.         return $this->loginDate;
  585.     }
  586.     public function setLoginDate(?\DateTimeInterface $loginDate): static
  587.     {
  588.         $this->loginDate $loginDate;
  589.         return $this;
  590.     }
  591.     public function getSubscribePausedTo(): ?\DateTimeInterface
  592.     {
  593.         return $this->subscribePausedTo;
  594.     }
  595.     public function setSubscribePausedTo(?\DateTimeInterface $subscribePausedTo): static
  596.     {
  597.         $this->subscribePausedTo $subscribePausedTo;
  598.         return $this;
  599.     }
  600.     public function getSubscribePausedReason(): ?string
  601.     {
  602.         return $this->subscribePausedReason;
  603.     }
  604.     public function setSubscribePausedReason(?string $subscribePausedReason): static
  605.     {
  606.         $this->subscribePausedReason $subscribePausedReason;
  607.         return $this;
  608.     }
  609.     public function getSource(): ?string
  610.     {
  611.         return $this->source;
  612.     }
  613.     public function setSource(?string $source): static
  614.     {
  615.         $this->source $source;
  616.         return $this;
  617.     }
  618.     public function getRating(): ?float
  619.     {
  620.         return $this->rating;
  621.     }
  622.     public function setRating(float $rating): static
  623.     {
  624.         $this->rating $rating;
  625.         return $this;
  626.     }
  627.     public function getActive(): ?string
  628.     {
  629.         return $this->active;
  630.     }
  631.     public function setActive(string $active): static
  632.     {
  633.         $this->active $active;
  634.         return $this;
  635.     }
  636.     public function getSocialNotice(): ?string
  637.     {
  638.         return $this->socialNotice;
  639.     }
  640.     public function setSocialNotice(string $socialNotice): static
  641.     {
  642.         $this->socialNotice $socialNotice;
  643.         return $this;
  644.     }
  645.     public function getAutoReject(): ?\DateTimeInterface
  646.     {
  647.         return $this->autoReject;
  648.     }
  649.     public function setAutoReject(?\DateTimeInterface $autoReject): static
  650.     {
  651.         $this->autoReject $autoReject;
  652.         return $this;
  653.     }
  654. }