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\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'customer',
  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(length20nullabletrue)]
  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(nullablefalse)]
  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. //
  140. //    #[ORM\OneToMany(mappedBy: 'owner', targetEntity: Ip::class)]
  141. //    private Collection $hetznerIps;
  142. //
  143. //    #[ORM\OneToMany(mappedBy: 'owner', targetEntity: Server::class)]
  144. //    private Collection $hetznerServers;
  145. //
  146. //    #[ORM\OneToMany(mappedBy: 'owner', targetEntity: StreamMasters::class)]
  147. //    private Collection $streamMasters;
  148. //
  149. //    #[ORM\OneToMany(mappedBy: 'owner', targetEntity: DonateKon::class)]
  150. //    private Collection $donateKons;
  151. //
  152. //    #[ORM\OneToMany(mappedBy: 'creator', targetEntity: Ticket::class)]
  153. //    private Collection $tickets;
  154. //
  155. //    #[ORM\OneToMany(mappedBy: 'author', targetEntity: TicketMessage::class)]
  156. //    private Collection $ticketMessages;
  157. //
  158. //    #[ORM\OneToMany(mappedBy: 'owner', targetEntity: \App\Entity\SAAS\Domain\Domain::class)]
  159. //    private Collection $boughtDomains;
  160. //
  161. //    #[ORM\OneToMany(mappedBy: 'owner', targetEntity: VasetPal::class)]
  162. //    private Collection $vasetPals;
  163.     public function getConnectedTelegramUserId(): ?array
  164.     {
  165.         return json_decode($this->connectedTelegramUserId true);
  166.     }
  167.     public function setConnectedTelegramUserId(?array $connectedTelegramUserId): static
  168.     {
  169.         $this->connectedTelegramUserId json_encode($connectedTelegramUserId);
  170.         return $this;
  171.     }
  172.     public function __construct()
  173.     {
  174.         parent::__construct();
  175.         $this->wallet 0;
  176.         $this->setVerifyCode(random_int(00000 99999));
  177.         $this->bots = new ArrayCollection();
  178.         $this->users = new ArrayCollection();
  179.         $this->transactions = new ArrayCollection();
  180.         $this->madeTransactions = new ArrayCollection();
  181.         $this->domains = new ArrayCollection();
  182.         $this->smsIncomes = new ArrayCollection();
  183.         $this->setSubUserCount(0);
  184.     }
  185.     public function hasRole($role)
  186.     {
  187.         return in_array($role$this->roles);
  188.     }
  189.     public function getId(): ?string
  190.     {
  191.         return $this->id;
  192.     }
  193.     public function getEmail(): ?string
  194.     {
  195.         return $this->email;
  196.     }
  197.     public function setEmail(string $email): static
  198.     {
  199.         $this->email $email;
  200.         return $this;
  201.     }
  202.     /**
  203.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  204.      */
  205.     public function getUsername(): string
  206.     {
  207.         return (string) $this->email;
  208.     }
  209.     /**
  210.      * @see UserInterface
  211.      */
  212.     public function getRoles(): array
  213.     {
  214.         $roles $this->roles;
  215.         // guarantee every user at least has ROLE_USER
  216.         $roles[] = 'ROLE_USER';
  217.         return array_unique($roles);
  218.     }
  219.     public function setRoles(array $roles): static
  220.     {
  221.         $this->roles $roles;
  222.         return $this;
  223.     }
  224.     /**
  225.      * @see PasswordAuthenticatedUserInterface
  226.      */
  227.     public function getPassword(): string
  228.     {
  229.         return $this->password;
  230.     }
  231.     public function setPassword(string $password): static
  232.     {
  233.         $this->password $password;
  234.         return $this;
  235.     }
  236.     /**
  237.      * Returning a salt is only needed, if you are not using a modern
  238.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  239.      *
  240.      * @see UserInterface
  241.      */
  242.     public function getSalt(): ?string
  243.     {
  244.         return null;
  245.     }
  246.     /**
  247.      * @see UserInterface
  248.      */
  249.     public function eraseCredentials(): void
  250.     {
  251.         // If you store any temporary, sensitive data on the user, clear it here
  252.         // $this->plainPassword = null;
  253.     }
  254.     public function getWallet(): ?string
  255.     {
  256.         return $this->wallet;
  257.     }
  258.     public function setWallet(string $wallet): static
  259.     {
  260.         $this->wallet $wallet;
  261.         return $this;
  262.     }
  263.     public function getWebsite(): ?Website
  264.     {
  265.         return $this->website;
  266.     }
  267.     public function setWebsite(?Website $shop): static
  268.     {
  269.         $this->website $shop;
  270.         return $this;
  271.     }
  272.     public function getMobile(): ?string
  273.     {
  274.         return $this->mobile;
  275.     }
  276.     public function setMobile(?string $mobile): void
  277.     {
  278.         $this->mobile $mobile;
  279.     }
  280.     public function getIdentifier(): string
  281.     {
  282.         return $this->identifier;
  283.     }
  284.     public function setIdentifier(string $identifier): void
  285.     {
  286.         $this->identifier $identifier;
  287.     }
  288.     public function isVerified(): bool
  289.     {
  290.         return $this->isVerified;
  291.     }
  292.     public function setIsVerified(bool $isVerified): void
  293.     {
  294.         $this->isVerified $isVerified;
  295.     }
  296.     public function getVerifyCode(): ?int
  297.     {
  298.         return $this->verifyCode;
  299.     }
  300.     public function setVerifyCode(?int $verifyCode): void
  301.     {
  302.         $this->verifyCode $verifyCode;
  303.     }
  304.     public function getLastName(): ?string
  305.     {
  306.         return $this->lastName;
  307.     }
  308.     public function setLastName(?string $lastName): static
  309.     {
  310.         $this->lastName $lastName;
  311.         return $this;
  312.     }
  313.     public function getFirstName(): mixed
  314.     {
  315.         return $this->firstName;
  316.     }
  317.     public function setFirstName(mixed $firstName): void
  318.     {
  319.         $this->firstName $firstName;
  320.     }
  321.     public function getPasswordResetAt(): ?\DateTimeInterface
  322.     {
  323.         return $this->passwordResetAt;
  324.     }
  325.     public function setPasswordResetAt(?\DateTimeInterface $passwordResetAt): static
  326.     {
  327.         $this->passwordResetAt $passwordResetAt;
  328.         return $this;
  329.     }
  330.     /**
  331.      * @return Collection<int, Bot>
  332.      */
  333.     public function getBots(): Collection
  334.     {
  335.         return $this->bots;
  336.     }
  337.     public function addBot(Bot $bot): static
  338.     {
  339.         if (!$this->bots->contains($bot)) {
  340.             $this->bots->add($bot);
  341.             $bot->setOwner($this);
  342.         }
  343.         return $this;
  344.     }
  345.     public function removeBot(Bot $bot): static
  346.     {
  347.         if ($this->bots->removeElement($bot)) {
  348.             // set the owning side to null (unless already changed)
  349.             if ($bot->getOwner() === $this) {
  350.                 $bot->setOwner(null);
  351.             }
  352.         }
  353.         return $this;
  354.     }
  355.     public function getLastlogin(): ?\DateTimeInterface
  356.     {
  357.         return $this->lastlogin;
  358.     }
  359.     public function setLastlogin(?\DateTimeInterface $lastlogin): static
  360.     {
  361.         $this->lastlogin $lastlogin;
  362.         return $this;
  363.     }
  364.     public function getPresenter(): ?self
  365.     {
  366.         return $this->presenter;
  367.     }
  368.     public function setPresenter(?self $presenter): static
  369.     {
  370.         $this->presenter $presenter;
  371.         return $this;
  372.     }
  373.     /**
  374.      * @return Collection<int, self>
  375.      */
  376.     public function getUsers(): Collection
  377.     {
  378.         return $this->users;
  379.     }
  380.     public function addUser(self $customer): static
  381.     {
  382.         if (!$this->users->contains($customer)) {
  383.             $this->users->add($customer);
  384.             $customer->setPresenter($this);
  385.         }
  386.         return $this;
  387.     }
  388.     public function removeUser(self $customer): static
  389.     {
  390.         if ($this->users->removeElement($customer)) {
  391.             // set the owning side to null (unless already changed)
  392.             if ($customer->getPresenter() === $this) {
  393.                 $customer->setPresenter(null);
  394.             }
  395.         }
  396.         return $this;
  397.     }
  398.     public function getVpnServicesCount(): ?int
  399.     {
  400.         return $this->VpnServicesCount;
  401.     }
  402.     public function setVpnServicesCount(?int $VpnServicesCount): void
  403.     {
  404.         $this->VpnServicesCount $VpnServicesCount;
  405.     }
  406.     public function getLastBuy(): ?DateTimeInterface
  407.     {
  408.         return $this->lastBuy;
  409.     }
  410.     public function setLastBuy(?DateTimeInterface $lastBuy): void
  411.     {
  412.         $this->lastBuy $lastBuy;
  413.     }
  414.     public function getSubUserCount(): ?int
  415.     {
  416.         return $this->subUserCount;
  417.     }
  418.     public function setSubUserCount(?int $subUserCount): void
  419.     {
  420.         $this->subUserCount $subUserCount;
  421.     }
  422.     public function getTelegramChannel(): ?string
  423.     {
  424.         return $this->telegramChannel;
  425.     }
  426.     public function setTelegramChannel(?string $telegramChannel): void
  427.     {
  428.         $this->telegramChannel $telegramChannel;
  429.     }
  430.     public function getCustomerText(): ?string
  431.     {
  432.         return $this->customerText;
  433.     }
  434.     public function setCustomerText(?string $customerText): void
  435.     {
  436.         $this->customerText $customerText;
  437.     }
  438.     public function getThisMonthCharge(): ?int
  439.     {
  440.         return $this->thisMonthCharge;
  441.     }
  442.     public function setThisMonthCharge(?int $thisMonthCharge): void
  443.     {
  444.         $this->thisMonthCharge $thisMonthCharge;
  445.     }
  446.     public function getUserTrace(): ?string
  447.     {
  448.         return $this->userTrace;
  449.     }
  450.     public function setUserTrace(?string $userTrace): void
  451.     {
  452.         $this->userTrace $userTrace;
  453.     }
  454.     public function getIsTelegramContact(): ?bool
  455.     {
  456.         return $this->isTelegramContact;
  457.     }
  458.     public function setIsTelegramContact(?bool $isTelegramContact): void
  459.     {
  460.         $this->isTelegramContact $isTelegramContact;
  461.     }
  462.     public function getIsTelegramContactChecked(): ?bool
  463.     {
  464.         return $this->isTelegramContactChecked;
  465.     }
  466.     public function setIsTelegramContactChecked(?bool $isTelegramContactChecked): void
  467.     {
  468.         $this->isTelegramContactChecked $isTelegramContactChecked;
  469.     }
  470.     public function getCardNumberToCharge(): ?string
  471.     {
  472.         return $this->cardNumberToCharge;
  473.     }
  474.     public function setCardNumberToCharge(?string $cardNumberToCharge): void
  475.     {
  476.         $this->cardNumberToCharge $cardNumberToCharge;
  477.     }
  478.     public function getAdvertiserMonthlyIncome(): ?string
  479.     {
  480.         return $this->advertiserMonthlyIncome;
  481.     }
  482.     public function setAdvertiserMonthlyIncome(?string $advertiserMonthlyIncome): void
  483.     {
  484.         $this->advertiserMonthlyIncome $advertiserMonthlyIncome;
  485.     }
  486.     /**
  487.      * @return mixed
  488.      */
  489.     public function getImage()
  490.     {
  491.         return $this->image;
  492.     }
  493.     /**
  494.      * @param mixed $image
  495.      */
  496.     public function setImage($image): void
  497.     {
  498.         $this->image $image;
  499.     }
  500.     public function getCampaign(): ?\App\Entity\Website\Campaign
  501.     {
  502.         return $this->campaign;
  503.     }
  504.     public function setCampaign(?\App\Entity\Website\Campaign $campaign): static
  505.     {
  506.         $this->campaign $campaign;
  507.         return $this;
  508.     }
  509.     /**
  510.      * @return Collection<int, Transaction>
  511.      */
  512.     public function getTransactions(): Collection
  513.     {
  514.         return $this->transactions;
  515.     }
  516.     public function addTransaction(Transaction $transaction): static
  517.     {
  518.         if (!$this->transactions->contains($transaction)) {
  519.             $this->transactions->add($transaction);
  520.             $transaction->setOwner($this);
  521.         }
  522.         return $this;
  523.     }
  524.     public function removeTransaction(Transaction $transaction): static
  525.     {
  526.         if ($this->transactions->removeElement($transaction)) {
  527.             // set the owning side to null (unless already changed)
  528.             if ($transaction->getOwner() === $this) {
  529.                 $transaction->setOwner(null);
  530.             }
  531.         }
  532.         return $this;
  533.     }
  534.     /**
  535.      * @return Collection<int, Transaction>
  536.      */
  537.     public function getMadeTransactions(): Collection
  538.     {
  539.         return $this->madeTransactions;
  540.     }
  541.     public function addMadeTransaction(Transaction $madeTransaction): static
  542.     {
  543.         if (!$this->madeTransactions->contains($madeTransaction)) {
  544.             $this->madeTransactions->add($madeTransaction);
  545.             $madeTransaction->setAuthor($this);
  546.         }
  547.         return $this;
  548.     }
  549.     public function removeMadeTransaction(Transaction $madeTransaction): static
  550.     {
  551.         if ($this->madeTransactions->removeElement($madeTransaction)) {
  552.             // set the owning side to null (unless already changed)
  553.             if ($madeTransaction->getAuthor() === $this) {
  554.                 $madeTransaction->setAuthor(null);
  555.             }
  556.         }
  557.         return $this;
  558.     }
  559.     /**
  560.      * @return Collection<int, \App\Entity\Website\Domains\Domain>
  561.      */
  562.     public function getDomains(): Collection
  563.     {
  564.         return $this->domains;
  565.     }
  566.     public function addDomain(\App\Entity\Website\Domains\Domain $domain): static
  567.     {
  568.         if (!$this->domains->contains($domain)) {
  569.             $this->domains->add($domain);
  570.             $domain->setOwner($this);
  571.         }
  572.         return $this;
  573.     }
  574.     public function removeDomain(\App\Entity\Website\Domains\Domain $domain): static
  575.     {
  576.         if ($this->domains->removeElement($domain)) {
  577.             // set the owning side to null (unless already changed)
  578.             if ($domain->getOwner() === $this) {
  579.                 $domain->setOwner(null);
  580.             }
  581.         }
  582.         return $this;
  583.     }
  584.     /**
  585.      * @return Collection<int, SmsIncome>
  586.      */
  587.     public function getSmsIncomes(): Collection
  588.     {
  589.         return $this->smsIncomes;
  590.     }
  591.     public function addSmsIncome(SmsIncome $smsIncome): static
  592.     {
  593.         if (!$this->smsIncomes->contains($smsIncome)) {
  594.             $this->smsIncomes->add($smsIncome);
  595.             $smsIncome->setOwner($this);
  596.         }
  597.         return $this;
  598.     }
  599.     public function removeSmsIncome(SmsIncome $smsIncome): static
  600.     {
  601.         if ($this->smsIncomes->removeElement($smsIncome)) {
  602.             // set the owning side to null (unless already changed)
  603.             if ($smsIncome->getOwner() === $this) {
  604.                 $smsIncome->setOwner(null);
  605.             }
  606.         }
  607.         return $this;
  608.     }
  609. }