src/Entity/UserStakeTokenEntity.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\Repository\UserStakeTokenRepository")
  10.  * @ORM\Table(name="user_stake_token")
  11.  * @ORM\HasLifecycleCallbacks()
  12.  */
  13. class UserStakeTokenEntity
  14. {
  15.     /**
  16.      * @ORM\Column(type="bigint")
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue(strategy="AUTO")
  19.      */
  20.     protected $id;
  21.     /**
  22.      * @ORM\Column(name="token_amount",type="decimal", precision=18, scale=8)
  23.      */
  24.     protected $tokenAmount;
  25.     
  26.     /**
  27.      * @ORM\Column(name="type", type="string", nullable=true)
  28.      */
  29.     protected $type;
  30.     /**
  31.      * @ORM\Column(name="token_dollar_value",type="decimal", precision=18, scale=8, nullable=true)
  32.      */
  33.     protected $tokenDollarValue;
  34.     /**
  35.      * @ORM\Column(name="interest",type="decimal", precision=18, scale=8, nullable=true)
  36.      */
  37.     protected $interest;
  38.     /**
  39.      * @ORM\Column(name="interest_percent", type="string", nullable=true)
  40.      */
  41.     protected $interestPercent;
  42.         /**
  43.      * @ORM\Column(type="string")
  44.      */
  45.     protected $status;
  46.         /**
  47.      * @ORM\Column(name="start_date", type="datetime", nullable=true)
  48.      */
  49.     protected $startDate;
  50.     /**
  51.      * @ORM\Column(name="end_date", type="datetime", nullable=true)
  52.      */
  53.     protected $endDate;
  54.     /**
  55.      * @ORM\Column(name="created_by", type="string", length=50)
  56.      */
  57.     protected $createdBy;
  58.     /**
  59.      * @ORM\Column(name="created_at", type="datetime")
  60.      */
  61.     protected $createdAt;
  62.     /**
  63.      * @ORM\Column(name="updated_by", type="string", length=50)
  64.      */
  65.     protected $updatedBy;
  66.     /**
  67.      * @ORM\Column(name="updated_at", type="datetime")
  68.      */
  69.     protected $updatedAt;
  70.     /**
  71.      * @ORM\ManyToOne(targetEntity="UserEntity", inversedBy="userStakeTokens")
  72.      * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
  73.      */
  74.     protected $user;
  75.     /**
  76.      * @ORM\OneToOne(targetEntity="UserUsdtEntity", inversedBy="userStakeToken", cascade={"remove"})
  77.      */
  78.     protected $userUsdt;
  79.     /**
  80.      * @ORM\OneToMany(targetEntity="UserBonusTokenEntity", mappedBy="userStakeToken", cascade={"remove"})
  81.      */
  82.     protected $userBonusTokens;
  83.     /**
  84.      * Set createdAt
  85.      *
  86.      * @ORM\PrePersist
  87.      */
  88.     public function setCreatedAtValue()
  89.     {
  90.         $this->createdBy = isset($_COOKIE['username']) ? $_COOKIE['username'] : 'System';
  91.         $this->createdAt = new \DateTime();
  92.         $this->updatedBy = isset($_COOKIE['username']) ? $_COOKIE['username'] : 'System';
  93.         $this->updatedAt = new \DateTime();
  94.         $this->status 'On Staking';
  95.     }
  96.     /**
  97.      * Set updatedAt
  98.      *
  99.      * @ORM\PreUpdate
  100.      */
  101.     public function setUpdatedAtValue()
  102.     {
  103.         $this->updatedBy = isset($_COOKIE['username']) ? $_COOKIE['username'] : 'System';
  104.         $this->updatedAt = new \DateTime();
  105.     }
  106.     public function __construct($data=null)
  107.     {
  108.         if(!is_null($data)) {
  109.         }
  110.         $this->userBonusTokens = new ArrayCollection();
  111.     }
  112.     /*--------------------------------------------------------------------------------------------------------*/
  113.     /*                    User Defined Setters and Getters                                                      */
  114.     /*--------------------------------------------------------------------------------------------------------*/
  115.     /**
  116.      * Get idEncoded
  117.      *
  118.      * @return string
  119.      */
  120.     public function getIdEncoded() {
  121.         return base64_encode($this->id);
  122.     }
  123.     /**
  124.      * Get bonus.
  125.      *
  126.      * @return UserBonusTokenEntity
  127.      */
  128.     public function getBonus()
  129.     {
  130.         foreach($this->getUserBonusTokens() as $bonus){
  131.             return $bonus;
  132.         }
  133.     }
  134.     public function getId(): ?string
  135.     {
  136.         return $this->id;
  137.     }
  138.     public function getAmount(): ?string
  139.     {
  140.         return $this->amount;
  141.     }
  142.     public function setAmount(string $amount): self
  143.     {
  144.         $this->amount $amount;
  145.         return $this;
  146.     }
  147.     public function getType(): ?string
  148.     {
  149.         return $this->type;
  150.     }
  151.     public function setType(?string $type): self
  152.     {
  153.         $this->type $type;
  154.         return $this;
  155.     }
  156.     public function getInterest(): ?string
  157.     {
  158.         return $this->interest;
  159.     }
  160.     public function setInterest(?string $interest): self
  161.     {
  162.         $this->interest $interest;
  163.         return $this;
  164.     }
  165.     public function getInterestPercent(): ?string
  166.     {
  167.         return $this->interestPercent;
  168.     }
  169.     public function setInterestPercent(?string $interestPercent): self
  170.     {
  171.         $this->interestPercent $interestPercent;
  172.         return $this;
  173.     }
  174.     public function getCreatedBy(): ?string
  175.     {
  176.         return $this->createdBy;
  177.     }
  178.     public function setCreatedBy(string $createdBy): self
  179.     {
  180.         $this->createdBy $createdBy;
  181.         return $this;
  182.     }
  183.     public function getCreatedAt(): ?\DateTimeInterface
  184.     {
  185.         return $this->createdAt;
  186.     }
  187.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  188.     {
  189.         $this->createdAt $createdAt;
  190.         return $this;
  191.     }
  192.     public function getUpdatedBy(): ?string
  193.     {
  194.         return $this->updatedBy;
  195.     }
  196.     public function setUpdatedBy(string $updatedBy): self
  197.     {
  198.         $this->updatedBy $updatedBy;
  199.         return $this;
  200.     }
  201.     public function getUpdatedAt(): ?\DateTimeInterface
  202.     {
  203.         return $this->updatedAt;
  204.     }
  205.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  206.     {
  207.         $this->updatedAt $updatedAt;
  208.         return $this;
  209.     }
  210.     public function getUser(): ?UserEntity
  211.     {
  212.         return $this->user;
  213.     }
  214.     public function setUser(?UserEntity $user): self
  215.     {
  216.         $this->user $user;
  217.         return $this;
  218.     }
  219.     public function getStartDate(): ?\DateTimeInterface
  220.     {
  221.         return $this->startDate;
  222.     }
  223.     public function setStartDate(?\DateTimeInterface $startDate): self
  224.     {
  225.         $this->startDate $startDate;
  226.         return $this;
  227.     }
  228.     public function getEndDate(): ?\DateTimeInterface
  229.     {
  230.         return $this->endDate;
  231.     }
  232.     public function setEndDate(?\DateTimeInterface $endDate): self
  233.     {
  234.         $this->endDate $endDate;
  235.         return $this;
  236.     }
  237.     public function getStatus(): ?string
  238.     {
  239.         return $this->status;
  240.     }
  241.     public function setStatus(string $status): self
  242.     {
  243.         $this->status $status;
  244.         return $this;
  245.     }
  246.     public function getTokenAmount(): ?string
  247.     {
  248.         return $this->tokenAmount;
  249.     }
  250.     public function setTokenAmount(string $tokenAmount): static
  251.     {
  252.         $this->tokenAmount $tokenAmount;
  253.         return $this;
  254.     }
  255.     public function getTokenDollarValue(): ?string
  256.     {
  257.         return $this->tokenDollarValue;
  258.     }
  259.     public function setTokenDollarValue(?string $tokenDollarValue): static
  260.     {
  261.         $this->tokenDollarValue $tokenDollarValue;
  262.         return $this;
  263.     }
  264.     public function getUserUsdt(): ?UserUsdtEntity
  265.     {
  266.         return $this->userUsdt;
  267.     }
  268.     public function setUserUsdt(?UserUsdtEntity $userUsdt): static
  269.     {
  270.         $this->userUsdt $userUsdt;
  271.         return $this;
  272.     }
  273.     /**
  274.      * @return Collection<int, UserBonusTokenEntity>
  275.      */
  276.     public function getUserBonusTokens(): Collection
  277.     {
  278.         return $this->userBonusTokens;
  279.     }
  280.     public function addUserBonusToken(UserBonusTokenEntity $userBonusToken): static
  281.     {
  282.         if (!$this->userBonusTokens->contains($userBonusToken)) {
  283.             $this->userBonusTokens->add($userBonusToken);
  284.             $userBonusToken->setUserStakeToken($this);
  285.         }
  286.         return $this;
  287.     }
  288.     public function removeUserBonusToken(UserBonusTokenEntity $userBonusToken): static
  289.     {
  290.         if ($this->userBonusTokens->removeElement($userBonusToken)) {
  291.             // set the owning side to null (unless already changed)
  292.             if ($userBonusToken->getUserStakeToken() === $this) {
  293.                 $userBonusToken->setUserStakeToken(null);
  294.             }
  295.         }
  296.         return $this;
  297.     }
  298. }