src/Entity/Generic/Customer/Customer.php line 34

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Generic\Customer;
  3. use App\Entity\BaseEntity;
  4. use App\Entity\Website\Campaign;
  5. use App\Entity\Website\Domains\Domain;
  6. //use App\Entity\SubTransactions\ArzDigital;
  7. //use App\Entity\SubTransactions\DonateKon;
  8. //use App\Entity\SubTransactions\StreamMasters;
  9. //use App\Entity\SubTransactions\VasetPal;
  10. use App\Entity\Website\VPN\Service\Service;
  11. use App\Entity\Website\Sms\SmsIncome;
  12. use App\Entity\Website\Telegram\AgentPublicBot\Bot;
  13. use App\Entity\Website\Transaction;
  14. use App\Entity\Website\Website\Website;
  15. use App\Repository\Generic\CustomerRepository;
  16. use DateTimeInterface;
  17. use Doctrine\Common\Collections\ArrayCollection;
  18. use Doctrine\Common\Collections\Collection;
  19. use Doctrine\DBAL\Types\Types;
  20. use Doctrine\ORM\Mapping as ORM;
  21. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  22. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  23. use Symfony\Component\Security\Core\User\UserInterface;
  24. #[ORM\Table(
  25.     name'user',
  26.     uniqueConstraints: [
  27.         new ORM\UniqueConstraint(name'shop_identifier_unique'columns: ['shop_id''identifier' 'mobile'])
  28.     ]
  29. )]
  30. #[ORM\Entity(repositoryClassCustomerRepository::class)]
  31. class Customer extends BaseEntity implements UserInterfacePasswordAuthenticatedUserInterface
  32. {
  33.     #[ORM\Id]
  34.     #[ORM\Column(type'guid'uniquetrue)]
  35.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  36.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  37.     private ?string $id;
  38.     #[ORM\Column(type'string'length255nullabletrue)]
  39.     private mixed $firstName;
  40.     #[ORM\Column(length180 nullabletrue)]
  41.     private ?string $email null;
  42.     #[ORM\Column]
  43.     private array $roles = [];
  44.     #[ORM\Column(length32nullabletrue)]
  45.     private ?string $mobile null;
  46.     #[ORM\Column(length180)]
  47.     private string $identifier// ایمیل یا شماره موبایل (برای ورود)
  48.     /**
  49.      * @var string The hashed password
  50.      */
  51.     #[ORM\Column]
  52.     private ?string $password null;
  53.     #[ORM\Column(type'boolean')]
  54.     private bool $isVerified false;
  55.     #[ORM\Column(typeTypes::BIGINT)]
  56.     private ?string $wallet null;
  57.     #[ORM\ManyToOne(inversedBy'customers')]
  58.     #[ORM\JoinColumn(nullabletrue)]
  59.     private ?Website $website null;
  60.     public function getUserIdentifier(): string
  61.     {
  62.         return $this->identifier;
  63.     }
  64.     public function __toString()
  65.     {
  66.         return $this->getIdentifier();
  67.     }
  68.     #[ORM\Column(nullabletrue)]
  69.     private ?int $verifyCode null;
  70.     #[ORM\Column(length255nullabletrue)]
  71.     private ?string $lastName null;
  72.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  73.     private ?\DateTimeInterface $passwordResetAt null;
  74.     #[ORM\OneToMany(mappedBy'owner'targetEntityBot::class)]
  75.     private Collection $bots;
  76.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  77.     private ?string $connectedTelegramUserId null;
  78.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  79.     private ?\DateTimeInterface $lastlogin null;
  80.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'customers')]
  81.     private ?self $presenter null;
  82.     #[ORM\OneToMany(mappedBy'presenter'targetEntityself::class)]
  83.     private Collection $users;
  84. //    ------------------------
  85. //    ------------------------
  86. //    ------------------------
  87.     #[ORM\Column(type'string'length255nullabletrue)]
  88.     private $image;
  89.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  90.     private ?DateTimeInterface $lastLogin null;
  91.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  92.     private ?\DateTimeInterface $lastBuy null;
  93.     #[ORM\Column]
  94.     private ?int $subUserCount null;
  95. //    /**
  96. //     * @var Collection<int, Service>
  97. //     */
  98. //    #[ORM\OneToMany(targetEntity: Service::class, mappedBy: 'owner')]
  99. //    private Collection $services;
  100.     #[ORM\Column(length255nullabletrue)]
  101.     private ?string $telegramChannel null;
  102.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  103.     private ?string $customerText null;
  104.     #[ORM\Column(nullabletrue)]
  105.     private ?int $thisMonthCharge null;
  106.     #[ORM\Column(length255nullabletrue)]
  107.     private ?string $userTrace null;
  108. //    #[ORM\ManyToOne(inversedBy: 'users')]
  109. //    private ?Campaign $campaign = null;
  110. //    #[ORM\OneToMany(mappedBy: 'owner', targetEntity: Domain::class)]
  111. //    private Collection $domains;
  112.     #[ORM\Column(nullabletrue)]
  113.     private ?bool $isTelegramContact null;
  114.     #[ORM\Column(nullabletrue)]
  115.     private ?bool $isTelegramContactChecked null;
  116. //    #[ORM\OneToMany(mappedBy: 'owner', targetEntity: \App\Entity\Telegram\AgentPublicBot\Bot::class)]
  117. //    private Collection $bots;
  118. //
  119. //    #[ORM\OneToMany(mappedBy: 'author', targetEntity: Idea::class)]
  120. //    private Collection $ideas;
  121.     #[ORM\Column(length255nullabletrue)]
  122.     private ?string $cardNumberToCharge null;
  123.     #[ORM\Column(typeTypes::BIGINTnullabletrue)]
  124.     private ?string $advertiserMonthlyIncome null;
  125. //    #[ORM\OneToMany(mappedBy: 'panelOwner', targetEntity: ArzDigital::class)]
  126. //    private Collection $arzDigitals;
  127.     #[ORM\Column(nullabletrue)]
  128.     private ?int $VpnServicesCount null;
  129.     #[ORM\ManyToOne(inversedBy'customers')]
  130.     private ?\App\Entity\Website\Campaign $campaign null;
  131.     #[ORM\OneToMany(mappedBy'owner'targetEntityTransaction::class)]
  132.     private Collection $transactions;
  133.     #[ORM\OneToMany(mappedBy'author'targetEntityTransaction::class)]
  134.     private Collection $madeTransactions;
  135.     #[ORM\OneToMany(mappedBy'owner'targetEntity\App\Entity\Website\Domains\Domain::class)]
  136.     private Collection $domains;
  137.     #[ORM\OneToMany(mappedBy'owner'targetEntitySmsIncome::class)]
  138.     private Collection $smsIncomes;
  139.     #[ORM\OneToMany(mappedBy'owner'targetEntity\App\Entity\Website\VPN\Service\Service::class)]
  140.     private Collection $services;
  141. //
  142. //    #[ORM\OneToMany(mappedBy: 'owner', targetEntity: Ip::class)]
  143. //    private Collection $hetznerIps;
  144. //
  145. //    #[ORM\OneToMany(mappedBy: 'owner', targetEntity: Server::class)]
  146. //    private Collection $hetznerServers;
  147. //
  148. //    #[ORM\OneToMany(mappedBy: 'owner', targetEntity: StreamMasters::class)]
  149. //    private Collection $streamMasters;
  150. //
  151. //    #[ORM\OneToMany(mappedBy: 'owner', targetEntity: DonateKon::class)]
  152. //    private Collection $donateKons;
  153. //
  154. //    #[ORM\OneToMany(mappedBy: 'creator', targetEntity: Ticket::class)]
  155. //    private Collection $tickets;
  156. //
  157. //    #[ORM\OneToMany(mappedBy: 'author', targetEntity: TicketMessage::class)]
  158. //    private Collection $ticketMessages;
  159. //
  160. //    #[ORM\OneToMany(mappedBy: 'owner', targetEntity: \App\Entity\SAAS\Domain\Domain::class)]
  161. //    private Collection $boughtDomains;
  162. //
  163. //    #[ORM\OneToMany(mappedBy: 'owner', targetEntity: VasetPal::class)]
  164. //    private Collection $vasetPals;
  165.     public function getConnectedTelegramUserId(): ?array
  166.     {
  167.         return json_decode($this->connectedTelegramUserId true);
  168.     }
  169.     public function setConnectedTelegramUserId(?array $connectedTelegramUserId): static
  170.     {
  171.         $this->connectedTelegramUserId json_encode($connectedTelegramUserId);
  172.         return $this;
  173.     }
  174.     public function __construct()
  175.     {
  176.         parent::__construct();
  177.         $this->wallet 0;
  178.         $this->setVerifyCode(random_int(00000 99999));
  179.         $this->bots = new ArrayCollection();
  180.         $this->users = new ArrayCollection();
  181.         $this->transactions = new ArrayCollection();
  182.         $this->madeTransactions = new ArrayCollection();
  183.         $this->domains = new ArrayCollection();
  184.         $this->smsIncomes = new ArrayCollection();
  185.         $this->setSubUserCount(0);
  186.         $this->services = new ArrayCollection();
  187.     }
  188.     public function hasRole($role)
  189.     {
  190.         return in_array($role$this->roles);
  191.     }
  192.     public function getId(): ?string
  193.     {
  194.         return $this->id;
  195.     }
  196.     public function getEmail(): ?string
  197.     {
  198.         return $this->email;
  199.     }
  200.     public function setEmail(string $email): static
  201.     {
  202.         $this->email $email;
  203.         return $this;
  204.     }
  205.     /**
  206.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  207.      */
  208.     public function getUsername(): string
  209.     {
  210.         return (string) $this->email;
  211.     }
  212.     /**
  213.      * @see UserInterface
  214.      */
  215.     public function getRoles(): array
  216.     {
  217.         $roles $this->roles;
  218.         // guarantee every user at least has ROLE_USER
  219.         $roles[] = 'ROLE_USER';
  220.         return array_unique($roles);
  221.     }
  222.     public function setRoles(array $roles): static
  223.     {
  224.         $this->roles $roles;
  225.         return $this;
  226.     }
  227.     /**
  228.      * @see PasswordAuthenticatedUserInterface
  229.      */
  230.     public function getPassword(): string
  231.     {
  232.         return $this->password;
  233.     }
  234.     public function setPassword(string $password): static
  235.     {
  236.         $this->password $password;
  237.         return $this;
  238.     }
  239.     /**
  240.      * Returning a salt is only needed, if you are not using a modern
  241.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  242.      *
  243.      * @see UserInterface
  244.      */
  245.     public function getSalt(): ?string
  246.     {
  247.         return null;
  248.     }
  249.     /**
  250.      * @see UserInterface
  251.      */
  252.     public function eraseCredentials(): void
  253.     {
  254.         // If you store any temporary, sensitive data on the user, clear it here
  255.         // $this->plainPassword = null;
  256.     }
  257.     public function getWallet(): ?string
  258.     {
  259.         return $this->wallet;
  260.     }
  261.     public function setWallet(string $wallet): static
  262.     {
  263.         $this->wallet $wallet;
  264.         return $this;
  265.     }
  266.     public function getWebsite(): ?Website
  267.     {
  268.         return $this->website;
  269.     }
  270.     public function setWebsite(?Website $shop): static
  271.     {
  272.         $this->website $shop;
  273.         return $this;
  274.     }
  275.     public function getMobile(): ?string
  276.     {
  277.         return $this->mobile;
  278.     }
  279.     public function setMobile(?string $mobile): void
  280.     {
  281.         $this->mobile $mobile;
  282.     }
  283.     public function getIdentifier(): string
  284.     {
  285.         return $this->identifier;
  286.     }
  287.     public function setIdentifier(string $identifier): void
  288.     {
  289.         $this->identifier $identifier;
  290.     }
  291.     public function isVerified(): bool
  292.     {
  293.         return $this->isVerified;
  294.     }
  295.     public function setIsVerified(bool $isVerified): void
  296.     {
  297.         $this->isVerified $isVerified;
  298.     }
  299.     public function getVerifyCode(): ?int
  300.     {
  301.         return $this->verifyCode;
  302.     }
  303.     public function setVerifyCode(?int $verifyCode): void
  304.     {
  305.         $this->verifyCode $verifyCode;
  306.     }
  307.     public function getLastName(): ?string
  308.     {
  309.         return $this->lastName;
  310.     }
  311.     public function setLastName(?string $lastName): static
  312.     {
  313.         $this->lastName $lastName;
  314.         return $this;
  315.     }
  316.     public function getFirstName(): mixed
  317.     {
  318.         return $this->firstName;
  319.     }
  320.     public function setFirstName(mixed $firstName): void
  321.     {
  322.         $this->firstName $firstName;
  323.     }
  324.     public function getPasswordResetAt(): ?\DateTimeInterface
  325.     {
  326.         return $this->passwordResetAt;
  327.     }
  328.     public function setPasswordResetAt(?\DateTimeInterface $passwordResetAt): static
  329.     {
  330.         $this->passwordResetAt $passwordResetAt;
  331.         return $this;
  332.     }
  333.     /**
  334.      * @return Collection<int, Bot>
  335.      */
  336.     public function getBots(): Collection
  337.     {
  338.         return $this->bots;
  339.     }
  340.     public function addBot(Bot $bot): static
  341.     {
  342.         if (!$this->bots->contains($bot)) {
  343.             $this->bots->add($bot);
  344.             $bot->setOwner($this);
  345.         }
  346.         return $this;
  347.     }
  348.     public function removeBot(Bot $bot): static
  349.     {
  350.         if ($this->bots->removeElement($bot)) {
  351.             // set the owning side to null (unless already changed)
  352.             if ($bot->getOwner() === $this) {
  353.                 $bot->setOwner(null);
  354.             }
  355.         }
  356.         return $this;
  357.     }
  358.     public function getLastlogin(): ?\DateTimeInterface
  359.     {
  360.         return $this->lastlogin;
  361.     }
  362.     public function setLastlogin(?\DateTimeInterface $lastlogin): static
  363.     {
  364.         $this->lastlogin $lastlogin;
  365.         return $this;
  366.     }
  367.     public function getPresenter(): ?self
  368.     {
  369.         return $this->presenter;
  370.     }
  371.     public function setPresenter(?self $presenter): static
  372.     {
  373.         $this->presenter $presenter;
  374.         return $this;
  375.     }
  376.     /**
  377.      * @return Collection<int, self>
  378.      */
  379.     public function getUsers(): Collection
  380.     {
  381.         return $this->users;
  382.     }
  383.     public function addUser(self $customer): static
  384.     {
  385.         if (!$this->users->contains($customer)) {
  386.             $this->users->add($customer);
  387.             $customer->setPresenter($this);
  388.         }
  389.         return $this;
  390.     }
  391.     public function removeUser(self $customer): static
  392.     {
  393.         if ($this->users->removeElement($customer)) {
  394.             // set the owning side to null (unless already changed)
  395.             if ($customer->getPresenter() === $this) {
  396.                 $customer->setPresenter(null);
  397.             }
  398.         }
  399.         return $this;
  400.     }
  401.     public function getVpnServicesCount(): ?int
  402.     {
  403.         return $this->VpnServicesCount;
  404.     }
  405.     public function setVpnServicesCount(?int $VpnServicesCount): void
  406.     {
  407.         $this->VpnServicesCount $VpnServicesCount;
  408.     }
  409.     public function getLastBuy(): ?DateTimeInterface
  410.     {
  411.         return $this->lastBuy;
  412.     }
  413.     public function setLastBuy(?DateTimeInterface $lastBuy): void
  414.     {
  415.         $this->lastBuy $lastBuy;
  416.     }
  417.     public function getSubUserCount(): ?int
  418.     {
  419.         return $this->subUserCount;
  420.     }
  421.     public function setSubUserCount(?int $subUserCount): void
  422.     {
  423.         $this->subUserCount $subUserCount;
  424.     }
  425.     public function getTelegramChannel(): ?string
  426.     {
  427.         return $this->telegramChannel;
  428.     }
  429.     public function setTelegramChannel(?string $telegramChannel): void
  430.     {
  431.         $this->telegramChannel $telegramChannel;
  432.     }
  433.     public function getCustomerText(): ?string
  434.     {
  435.         return $this->customerText;
  436.     }
  437.     public function setCustomerText(?string $customerText): void
  438.     {
  439.         $this->customerText $customerText;
  440.     }
  441.     public function getThisMonthCharge(): ?int
  442.     {
  443.         return $this->thisMonthCharge;
  444.     }
  445.     public function setThisMonthCharge(?int $thisMonthCharge): void
  446.     {
  447.         $this->thisMonthCharge $thisMonthCharge;
  448.     }
  449.     public function getUserTrace(): ?string
  450.     {
  451.         return $this->userTrace;
  452.     }
  453.     public function setUserTrace(?string $userTrace): void
  454.     {
  455.         $this->userTrace $userTrace;
  456.     }
  457.     public function getIsTelegramContact(): ?bool
  458.     {
  459.         return $this->isTelegramContact;
  460.     }
  461.     public function setIsTelegramContact(?bool $isTelegramContact): void
  462.     {
  463.         $this->isTelegramContact $isTelegramContact;
  464.     }
  465.     public function getIsTelegramContactChecked(): ?bool
  466.     {
  467.         return $this->isTelegramContactChecked;
  468.     }
  469.     public function setIsTelegramContactChecked(?bool $isTelegramContactChecked): void
  470.     {
  471.         $this->isTelegramContactChecked $isTelegramContactChecked;
  472.     }
  473.     public function getCardNumberToCharge(): ?string
  474.     {
  475.         return $this->cardNumberToCharge;
  476.     }
  477.     public function setCardNumberToCharge(?string $cardNumberToCharge): void
  478.     {
  479.         $this->cardNumberToCharge $cardNumberToCharge;
  480.     }
  481.     public function getAdvertiserMonthlyIncome(): ?string
  482.     {
  483.         return $this->advertiserMonthlyIncome;
  484.     }
  485.     public function setAdvertiserMonthlyIncome(?string $advertiserMonthlyIncome): void
  486.     {
  487.         $this->advertiserMonthlyIncome $advertiserMonthlyIncome;
  488.     }
  489.     /**
  490.      * @return mixed
  491.      */
  492.     public function getImage()
  493.     {
  494.         return $this->image;
  495.     }
  496.     /**
  497.      * @param mixed $image
  498.      */
  499.     public function setImage($image): void
  500.     {
  501.         $this->image $image;
  502.     }
  503.     public function getCampaign(): ?\App\Entity\Website\Campaign
  504.     {
  505.         return $this->campaign;
  506.     }
  507.     public function setCampaign(?\App\Entity\Website\Campaign $campaign): static
  508.     {
  509.         $this->campaign $campaign;
  510.         return $this;
  511.     }
  512.     /**
  513.      * @return Collection<int, Transaction>
  514.      */
  515.     public function getTransactions(): Collection
  516.     {
  517.         return $this->transactions;
  518.     }
  519.     public function addTransaction(Transaction $transaction): static
  520.     {
  521.         if (!$this->transactions->contains($transaction)) {
  522.             $this->transactions->add($transaction);
  523.             $transaction->setOwner($this);
  524.         }
  525.         return $this;
  526.     }
  527.     public function removeTransaction(Transaction $transaction): static
  528.     {
  529.         if ($this->transactions->removeElement($transaction)) {
  530.             // set the owning side to null (unless already changed)
  531.             if ($transaction->getOwner() === $this) {
  532.                 $transaction->setOwner(null);
  533.             }
  534.         }
  535.         return $this;
  536.     }
  537.     /**
  538.      * @return Collection<int, Transaction>
  539.      */
  540.     public function getMadeTransactions(): Collection
  541.     {
  542.         return $this->madeTransactions;
  543.     }
  544.     public function addMadeTransaction(Transaction $madeTransaction): static
  545.     {
  546.         if (!$this->madeTransactions->contains($madeTransaction)) {
  547.             $this->madeTransactions->add($madeTransaction);
  548.             $madeTransaction->setAuthor($this);
  549.         }
  550.         return $this;
  551.     }
  552.     public function removeMadeTransaction(Transaction $madeTransaction): static
  553.     {
  554.         if ($this->madeTransactions->removeElement($madeTransaction)) {
  555.             // set the owning side to null (unless already changed)
  556.             if ($madeTransaction->getAuthor() === $this) {
  557.                 $madeTransaction->setAuthor(null);
  558.             }
  559.         }
  560.         return $this;
  561.     }
  562.     /**
  563.      * @return Collection<int, \App\Entity\Website\Domains\Domain>
  564.      */
  565.     public function getDomains(): Collection
  566.     {
  567.         return $this->domains;
  568.     }
  569.     public function addDomain(\App\Entity\Website\Domains\Domain $domain): static
  570.     {
  571.         if (!$this->domains->contains($domain)) {
  572.             $this->domains->add($domain);
  573.             $domain->setOwner($this);
  574.         }
  575.         return $this;
  576.     }
  577.     public function removeDomain(\App\Entity\Website\Domains\Domain $domain): static
  578.     {
  579.         if ($this->domains->removeElement($domain)) {
  580.             // set the owning side to null (unless already changed)
  581.             if ($domain->getOwner() === $this) {
  582.                 $domain->setOwner(null);
  583.             }
  584.         }
  585.         return $this;
  586.     }
  587.     /**
  588.      * @return Collection<int, SmsIncome>
  589.      */
  590.     public function getSmsIncomes(): Collection
  591.     {
  592.         return $this->smsIncomes;
  593.     }
  594.     public function addSmsIncome(SmsIncome $smsIncome): static
  595.     {
  596.         if (!$this->smsIncomes->contains($smsIncome)) {
  597.             $this->smsIncomes->add($smsIncome);
  598.             $smsIncome->setOwner($this);
  599.         }
  600.         return $this;
  601.     }
  602.     public function removeSmsIncome(SmsIncome $smsIncome): static
  603.     {
  604.         if ($this->smsIncomes->removeElement($smsIncome)) {
  605.             // set the owning side to null (unless already changed)
  606.             if ($smsIncome->getOwner() === $this) {
  607.                 $smsIncome->setOwner(null);
  608.             }
  609.         }
  610.         return $this;
  611.     }
  612.     /**
  613.      * @return Collection<int, \App\Entity\Website\VPN\Service\Service>
  614.      */
  615.     public function getServices(): Collection
  616.     {
  617.         return $this->services;
  618.     }
  619.     public function addService(\App\Entity\Website\VPN\Service\Service $service): static
  620.     {
  621.         if (!$this->services->contains($service)) {
  622.             $this->services->add($service);
  623.             $service->setOwner($this);
  624.         }
  625.         return $this;
  626.     }
  627.     public function removeService(\App\Entity\Website\VPN\Service\Service $service): static
  628.     {
  629.         if ($this->services->removeElement($service)) {
  630.             // set the owning side to null (unless already changed)
  631.             if ($service->getOwner() === $this) {
  632.                 $service->setOwner(null);
  633.             }
  634.         }
  635.         return $this;
  636.     }
  637. }