<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
/**
* @ORM\Entity(repositoryClass="App\Repository\UserStakeTokenRepository")
* @ORM\Table(name="user_stake_token")
* @ORM\HasLifecycleCallbacks()
*/
class UserStakeTokenEntity
{
/**
* @ORM\Column(type="bigint")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(name="token_amount",type="decimal", precision=18, scale=8)
*/
protected $tokenAmount;
/**
* @ORM\Column(name="type", type="string", nullable=true)
*/
protected $type;
/**
* @ORM\Column(name="token_dollar_value",type="decimal", precision=18, scale=8, nullable=true)
*/
protected $tokenDollarValue;
/**
* @ORM\Column(name="interest",type="decimal", precision=18, scale=8, nullable=true)
*/
protected $interest;
/**
* @ORM\Column(name="interest_percent", type="string", nullable=true)
*/
protected $interestPercent;
/**
* @ORM\Column(type="string")
*/
protected $status;
/**
* @ORM\Column(name="start_date", type="datetime", nullable=true)
*/
protected $startDate;
/**
* @ORM\Column(name="end_date", type="datetime", nullable=true)
*/
protected $endDate;
/**
* @ORM\Column(name="created_by", type="string", length=50)
*/
protected $createdBy;
/**
* @ORM\Column(name="created_at", type="datetime")
*/
protected $createdAt;
/**
* @ORM\Column(name="updated_by", type="string", length=50)
*/
protected $updatedBy;
/**
* @ORM\Column(name="updated_at", type="datetime")
*/
protected $updatedAt;
/**
* @ORM\ManyToOne(targetEntity="UserEntity", inversedBy="userStakeTokens")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
protected $user;
/**
* @ORM\OneToOne(targetEntity="UserUsdtEntity", inversedBy="userStakeToken", cascade={"remove"})
*/
protected $userUsdt;
/**
* @ORM\OneToMany(targetEntity="UserBonusTokenEntity", mappedBy="userStakeToken", cascade={"remove"})
*/
protected $userBonusTokens;
/**
* Set createdAt
*
* @ORM\PrePersist
*/
public function setCreatedAtValue()
{
$this->createdBy = isset($_COOKIE['username']) ? $_COOKIE['username'] : 'System';
$this->createdAt = new \DateTime();
$this->updatedBy = isset($_COOKIE['username']) ? $_COOKIE['username'] : 'System';
$this->updatedAt = new \DateTime();
$this->status = 'On Staking';
}
/**
* Set updatedAt
*
* @ORM\PreUpdate
*/
public function setUpdatedAtValue()
{
$this->updatedBy = isset($_COOKIE['username']) ? $_COOKIE['username'] : 'System';
$this->updatedAt = new \DateTime();
}
public function __construct($data=null)
{
if(!is_null($data)) {
}
$this->userBonusTokens = new ArrayCollection();
}
/*--------------------------------------------------------------------------------------------------------*/
/* User Defined Setters and Getters */
/*--------------------------------------------------------------------------------------------------------*/
/**
* Get idEncoded
*
* @return string
*/
public function getIdEncoded() {
return base64_encode($this->id);
}
/**
* Get bonus.
*
* @return UserBonusTokenEntity
*/
public function getBonus()
{
foreach($this->getUserBonusTokens() as $bonus){
return $bonus;
}
}
public function getId(): ?string
{
return $this->id;
}
public function getAmount(): ?string
{
return $this->amount;
}
public function setAmount(string $amount): self
{
$this->amount = $amount;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): self
{
$this->type = $type;
return $this;
}
public function getInterest(): ?string
{
return $this->interest;
}
public function setInterest(?string $interest): self
{
$this->interest = $interest;
return $this;
}
public function getInterestPercent(): ?string
{
return $this->interestPercent;
}
public function setInterestPercent(?string $interestPercent): self
{
$this->interestPercent = $interestPercent;
return $this;
}
public function getCreatedBy(): ?string
{
return $this->createdBy;
}
public function setCreatedBy(string $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedBy(): ?string
{
return $this->updatedBy;
}
public function setUpdatedBy(string $updatedBy): self
{
$this->updatedBy = $updatedBy;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getUser(): ?UserEntity
{
return $this->user;
}
public function setUser(?UserEntity $user): self
{
$this->user = $user;
return $this;
}
public function getStartDate(): ?\DateTimeInterface
{
return $this->startDate;
}
public function setStartDate(?\DateTimeInterface $startDate): self
{
$this->startDate = $startDate;
return $this;
}
public function getEndDate(): ?\DateTimeInterface
{
return $this->endDate;
}
public function setEndDate(?\DateTimeInterface $endDate): self
{
$this->endDate = $endDate;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
public function getTokenAmount(): ?string
{
return $this->tokenAmount;
}
public function setTokenAmount(string $tokenAmount): static
{
$this->tokenAmount = $tokenAmount;
return $this;
}
public function getTokenDollarValue(): ?string
{
return $this->tokenDollarValue;
}
public function setTokenDollarValue(?string $tokenDollarValue): static
{
$this->tokenDollarValue = $tokenDollarValue;
return $this;
}
public function getUserUsdt(): ?UserUsdtEntity
{
return $this->userUsdt;
}
public function setUserUsdt(?UserUsdtEntity $userUsdt): static
{
$this->userUsdt = $userUsdt;
return $this;
}
/**
* @return Collection<int, UserBonusTokenEntity>
*/
public function getUserBonusTokens(): Collection
{
return $this->userBonusTokens;
}
public function addUserBonusToken(UserBonusTokenEntity $userBonusToken): static
{
if (!$this->userBonusTokens->contains($userBonusToken)) {
$this->userBonusTokens->add($userBonusToken);
$userBonusToken->setUserStakeToken($this);
}
return $this;
}
public function removeUserBonusToken(UserBonusTokenEntity $userBonusToken): static
{
if ($this->userBonusTokens->removeElement($userBonusToken)) {
// set the owning side to null (unless already changed)
if ($userBonusToken->getUserStakeToken() === $this) {
$userBonusToken->setUserStakeToken(null);
}
}
return $this;
}
}