<?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\UserMemeCoinRepository")
* @ORM\Table(name="user_meme_coin")
* @ORM\HasLifecycleCallbacks()
*/
class UserMemeCoinEntity
{
/**
* @ORM\Column(type="bigint")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(name="name",type="string", nullable=false)
*/
protected $name;
/**
* @ORM\Column(name="symbol",type="string", nullable=false)
*/
protected $symbol;
/**
* @ORM\Column(name="total_supply",type="decimal", precision=18, scale=8, nullable=true)
*/
protected $totalSupply;
/**
* @ORM\Column(name="base_price",type="decimal", precision=18, scale=8, nullable=true)
*/
protected $basePrice;
/**
* @ORM\Column(name="burn_amount",type="decimal", precision=18, scale=8, nullable=true)
*/
protected $burnAmount;
/**
* @ORM\Column(name="recycle_amount",type="decimal", precision=18, scale=8, nullable=true)
*/
protected $recycleAmount;
/**
* @ORM\Column(name="status", type="string")
*/
protected $status;
/**
* @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="userMemecoins")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
protected $user;
/**
* @ORM\OneToMany(targetEntity="UserMemeCoinTransactionEntity", mappedBy="userMemeCoin", cascade={"remove"})
*/
protected $userMemeCoinTransactions;
/**
* 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 = 'Active';
}
/**
* 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->userMemeCoinTransactions = new ArrayCollection();
}
/*--------------------------------------------------------------------------------------------------------*/
/* User Defined Setters and Getters */
/*--------------------------------------------------------------------------------------------------------*/
/**
* Get remainingSupply
*
* @return string
*/
public function remainingSupply() {
$supply = $this->getTotalSupply();
foreach ($this->getUserMemeCoinTransactions() as $transaction){
$supply -= $transaction->getAmount();
}
return $supply;
}
/**
* Get idEncoded
*
* @return string
*/
public function getIdEncoded() {
return base64_encode($this->id);
}
public function getId(): ?string
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getSymbol(): ?string
{
return $this->symbol;
}
public function setSymbol(string $symbol): static
{
$this->symbol = $symbol;
return $this;
}
public function getTotalSupply(): ?int
{
return $this->totalSupply;
}
public function setTotalSupply(int $totalSupply): static
{
$this->totalSupply = $totalSupply;
return $this;
}
public function getBasePrice(): ?string
{
return $this->basePrice;
}
public function setBasePrice(?string $basePrice): static
{
$this->basePrice = $basePrice;
return $this;
}
public function getBurnAmount(): ?string
{
return $this->burnAmount;
}
public function setBurnAmount(?string $burnAmount): static
{
$this->burnAmount = $burnAmount;
return $this;
}
public function getRecycleAmount(): ?string
{
return $this->recycleAmount;
}
public function setRecycleAmount(?string $recycleAmount): static
{
$this->recycleAmount = $recycleAmount;
return $this;
}
public function getCreatedBy(): ?string
{
return $this->createdBy;
}
public function setCreatedBy(string $createdBy): static
{
$this->createdBy = $createdBy;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): static
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedBy(): ?string
{
return $this->updatedBy;
}
public function setUpdatedBy(string $updatedBy): static
{
$this->updatedBy = $updatedBy;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): static
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getUser(): ?UserEntity
{
return $this->user;
}
public function setUser(?UserEntity $user): static
{
$this->user = $user;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): static
{
$this->status = $status;
return $this;
}
/**
* @return Collection<int, UserMemeCoinTransactionEntity>
*/
public function getUserMemeCoinTransactions(): Collection
{
return $this->userMemeCoinTransactions;
}
public function addUserMemeCoinTransaction(UserMemeCoinTransactionEntity $userMemeCoinTransaction): static
{
if (!$this->userMemeCoinTransactions->contains($userMemeCoinTransaction)) {
$this->userMemeCoinTransactions->add($userMemeCoinTransaction);
$userMemeCoinTransaction->setUserMemeCoin($this);
}
return $this;
}
public function removeUserMemeCoinTransaction(UserMemeCoinTransactionEntity $userMemeCoinTransaction): static
{
if ($this->userMemeCoinTransactions->removeElement($userMemeCoinTransaction)) {
// set the owning side to null (unless already changed)
if ($userMemeCoinTransaction->getUserMemeCoin() === $this) {
$userMemeCoinTransaction->setUserMemeCoin(null);
}
}
return $this;
}
}