src/Entity/UserMemeCoinEntity.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\UserMemeCoinRepository")
  10.  * @ORM\Table(name="user_meme_coin")
  11.  * @ORM\HasLifecycleCallbacks()
  12.  */
  13. class UserMemeCoinEntity
  14. {
  15.     /**
  16.      * @ORM\Column(type="bigint")
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue(strategy="AUTO")
  19.      */
  20.     protected $id;
  21.     /**
  22.      * @ORM\Column(name="name",type="string", nullable=false)
  23.      */
  24.     protected $name;
  25.     
  26.     /**
  27.      * @ORM\Column(name="symbol",type="string", nullable=false)
  28.      */
  29.     protected $symbol;
  30.     /**
  31.      * @ORM\Column(name="total_supply",type="decimal", precision=18, scale=8, nullable=true)
  32.      */
  33.     protected $totalSupply;
  34.     /**
  35.      * @ORM\Column(name="base_price",type="decimal", precision=18, scale=8, nullable=true)
  36.      */
  37.     protected $basePrice;
  38.     /**
  39.      * @ORM\Column(name="burn_amount",type="decimal", precision=18, scale=8, nullable=true)
  40.      */
  41.     protected $burnAmount;
  42.     
  43.     /**
  44.      * @ORM\Column(name="recycle_amount",type="decimal", precision=18, scale=8, nullable=true)
  45.      */
  46.     protected $recycleAmount;
  47.     /**
  48.      * @ORM\Column(name="status", type="string")
  49.      */
  50.     protected $status;
  51.     
  52.     /**
  53.      * @ORM\Column(name="created_by", type="string", length=50)
  54.      */
  55.     protected $createdBy;
  56.     /**
  57.      * @ORM\Column(name="created_at", type="datetime")
  58.      */
  59.     protected $createdAt;
  60.     /**
  61.      * @ORM\Column(name="updated_by", type="string", length=50)
  62.      */
  63.     protected $updatedBy;
  64.     /**
  65.      * @ORM\Column(name="updated_at", type="datetime")
  66.      */
  67.     protected $updatedAt;
  68.     /**
  69.      * @ORM\ManyToOne(targetEntity="UserEntity", inversedBy="userMemecoins")
  70.      * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
  71.      */
  72.     protected $user;
  73.     
  74.      /**
  75.      * @ORM\OneToMany(targetEntity="UserMemeCoinTransactionEntity", mappedBy="userMemeCoin", cascade={"remove"})
  76.      */
  77.     protected $userMemeCoinTransactions;
  78.     
  79.     /**
  80.      * Set createdAt
  81.      *
  82.      * @ORM\PrePersist
  83.      */
  84.     public function setCreatedAtValue()
  85.     {
  86.         $this->createdBy = isset($_COOKIE['username']) ? $_COOKIE['username'] : 'System';
  87.         $this->createdAt = new \DateTime();
  88.         $this->updatedBy = isset($_COOKIE['username']) ? $_COOKIE['username'] : 'System';
  89.         $this->updatedAt = new \DateTime();
  90.         $this->status 'Active';
  91.     }
  92.     /**
  93.      * Set updatedAt
  94.      *
  95.      * @ORM\PreUpdate
  96.      */
  97.     public function setUpdatedAtValue()
  98.     {
  99.         $this->updatedBy = isset($_COOKIE['username']) ? $_COOKIE['username'] : 'System';
  100.         $this->updatedAt = new \DateTime();
  101.     }
  102.     public function __construct($data=null)
  103.     {
  104.         if(!is_null($data)) {
  105.         }
  106.         $this->userMemeCoinTransactions = new ArrayCollection();
  107.     }
  108.     /*--------------------------------------------------------------------------------------------------------*/
  109.     /*                    User Defined Setters and Getters                                                      */
  110.     /*--------------------------------------------------------------------------------------------------------*/
  111.      /**
  112.      * Get remainingSupply
  113.      *
  114.      * @return string
  115.      */
  116.     public function remainingSupply() {
  117.         $supply $this->getTotalSupply();
  118.         foreach ($this->getUserMemeCoinTransactions() as $transaction){
  119.             $supply -= $transaction->getAmount();
  120.         }
  121.         return $supply;
  122.     }
  123.     /**
  124.      * Get idEncoded
  125.      *
  126.      * @return string
  127.      */
  128.     public function getIdEncoded() {
  129.         return base64_encode($this->id);
  130.     }
  131.     public function getId(): ?string
  132.     {
  133.         return $this->id;
  134.     }
  135.     public function getName(): ?string
  136.     {
  137.         return $this->name;
  138.     }
  139.     public function setName(string $name): static
  140.     {
  141.         $this->name $name;
  142.         return $this;
  143.     }
  144.     public function getSymbol(): ?string
  145.     {
  146.         return $this->symbol;
  147.     }
  148.     public function setSymbol(string $symbol): static
  149.     {
  150.         $this->symbol $symbol;
  151.         return $this;
  152.     }
  153.     public function getTotalSupply(): ?int
  154.     {
  155.         return $this->totalSupply;
  156.     }
  157.     public function setTotalSupply(int $totalSupply): static
  158.     {
  159.         $this->totalSupply $totalSupply;
  160.         return $this;
  161.     }
  162.     public function getBasePrice(): ?string
  163.     {
  164.         return $this->basePrice;
  165.     }
  166.     public function setBasePrice(?string $basePrice): static
  167.     {
  168.         $this->basePrice $basePrice;
  169.         return $this;
  170.     }
  171.     public function getBurnAmount(): ?string
  172.     {
  173.         return $this->burnAmount;
  174.     }
  175.     public function setBurnAmount(?string $burnAmount): static
  176.     {
  177.         $this->burnAmount $burnAmount;
  178.         return $this;
  179.     }
  180.     public function getRecycleAmount(): ?string
  181.     {
  182.         return $this->recycleAmount;
  183.     }
  184.     public function setRecycleAmount(?string $recycleAmount): static
  185.     {
  186.         $this->recycleAmount $recycleAmount;
  187.         return $this;
  188.     }
  189.     public function getCreatedBy(): ?string
  190.     {
  191.         return $this->createdBy;
  192.     }
  193.     public function setCreatedBy(string $createdBy): static
  194.     {
  195.         $this->createdBy $createdBy;
  196.         return $this;
  197.     }
  198.     public function getCreatedAt(): ?\DateTimeInterface
  199.     {
  200.         return $this->createdAt;
  201.     }
  202.     public function setCreatedAt(\DateTimeInterface $createdAt): static
  203.     {
  204.         $this->createdAt $createdAt;
  205.         return $this;
  206.     }
  207.     public function getUpdatedBy(): ?string
  208.     {
  209.         return $this->updatedBy;
  210.     }
  211.     public function setUpdatedBy(string $updatedBy): static
  212.     {
  213.         $this->updatedBy $updatedBy;
  214.         return $this;
  215.     }
  216.     public function getUpdatedAt(): ?\DateTimeInterface
  217.     {
  218.         return $this->updatedAt;
  219.     }
  220.     public function setUpdatedAt(\DateTimeInterface $updatedAt): static
  221.     {
  222.         $this->updatedAt $updatedAt;
  223.         return $this;
  224.     }
  225.     public function getUser(): ?UserEntity
  226.     {
  227.         return $this->user;
  228.     }
  229.     public function setUser(?UserEntity $user): static
  230.     {
  231.         $this->user $user;
  232.         return $this;
  233.     }
  234.     public function getStatus(): ?string
  235.     {
  236.         return $this->status;
  237.     }
  238.     public function setStatus(string $status): static
  239.     {
  240.         $this->status $status;
  241.         return $this;
  242.     }
  243.     /**
  244.      * @return Collection<int, UserMemeCoinTransactionEntity>
  245.      */
  246.     public function getUserMemeCoinTransactions(): Collection
  247.     {
  248.         return $this->userMemeCoinTransactions;
  249.     }
  250.     public function addUserMemeCoinTransaction(UserMemeCoinTransactionEntity $userMemeCoinTransaction): static
  251.     {
  252.         if (!$this->userMemeCoinTransactions->contains($userMemeCoinTransaction)) {
  253.             $this->userMemeCoinTransactions->add($userMemeCoinTransaction);
  254.             $userMemeCoinTransaction->setUserMemeCoin($this);
  255.         }
  256.         return $this;
  257.     }
  258.     public function removeUserMemeCoinTransaction(UserMemeCoinTransactionEntity $userMemeCoinTransaction): static
  259.     {
  260.         if ($this->userMemeCoinTransactions->removeElement($userMemeCoinTransaction)) {
  261.             // set the owning side to null (unless already changed)
  262.             if ($userMemeCoinTransaction->getUserMemeCoin() === $this) {
  263.                 $userMemeCoinTransaction->setUserMemeCoin(null);
  264.             }
  265.         }
  266.         return $this;
  267.     }
  268.   
  269. }