src/Entity/UserAdjustedTokenEntity.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
  7. /**
  8.  * @ORM\Entity(repositoryClass="App\Repository\UserAdjustedTokenRepository")
  9.  * @ORM\Table(name="user_adjusted_token")
  10.  * @ORM\HasLifecycleCallbacks()
  11.  */
  12. class UserAdjustedTokenEntity
  13. {
  14.     /**
  15.      * @ORM\Column(type="bigint")
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue(strategy="AUTO")
  18.      */
  19.     protected $id;
  20.     /**
  21.      * @ORM\Column(name="amount",type="decimal", precision=18, scale=8)
  22.      */
  23.     protected $amount;
  24.     /**
  25.      * @ORM\Column(name="created_by", type="string", length=50)
  26.      */
  27.     protected $createdBy;
  28.     /**
  29.      * @ORM\Column(name="created_at", type="datetime")
  30.      */
  31.     protected $createdAt;
  32.     /**
  33.      * @ORM\Column(name="updated_by", type="string", length=50)
  34.      */
  35.     protected $updatedBy;
  36.     /**
  37.      * @ORM\Column(name="updated_at", type="datetime")
  38.      */
  39.     protected $updatedAt;
  40.     /**
  41.      * @ORM\ManyToOne(targetEntity="UserEntity", inversedBy="userAdjustedTokens")
  42.      * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
  43.      */
  44.     protected $user;
  45.     /**
  46.      * Set createdAt
  47.      *
  48.      * @ORM\PrePersist
  49.      */
  50.     public function setCreatedAtValue()
  51.     {
  52.         $this->createdBy = isset($_COOKIE['username']) ? $_COOKIE['username'] : 'System';
  53.         $this->createdAt = new \DateTime();
  54.         $this->updatedBy = isset($_COOKIE['username']) ? $_COOKIE['username'] : 'System';
  55.         $this->updatedAt = new \DateTime();
  56.     }
  57.     /**
  58.      * Set updatedAt
  59.      *
  60.      * @ORM\PreUpdate
  61.      */
  62.     public function setUpdatedAtValue()
  63.     {
  64.         $this->updatedBy = isset($_COOKIE['username']) ? $_COOKIE['username'] : 'System';
  65.         $this->updatedAt = new \DateTime();
  66.     }
  67.     public function __construct($data=null)
  68.     {
  69.         if(!is_null($data)) {
  70.         }
  71.     }
  72.     /*--------------------------------------------------------------------------------------------------------*/
  73.     /*                    User Defined Setters and Getters                                                      */
  74.     /*--------------------------------------------------------------------------------------------------------*/
  75.     /**
  76.      * Get idEncoded
  77.      *
  78.      * @return string
  79.      */
  80.     public function getIdEncoded() {
  81.         return base64_encode($this->id);
  82.     }
  83.     /**
  84.      * Get parsedId
  85.      *
  86.      * @return string
  87.      */
  88.     public function getParsedId() {
  89.         return sprintf("%06d"$this->id);
  90.     }
  91.     /**
  92.      * Get createdAtAsString
  93.      *
  94.      * @return string
  95.      */
  96.     public function getCreatedAtAsString()
  97.     {
  98.         $dttst = new DateTimeToStringTransformer();
  99.         return !empty($this->createdAt) ? date('m/d/Y'strtotime($dttst->transform($this->createdAt))) : '';
  100.     }
  101.     /*--------------------------------------------------------------------------------------------------------*/
  102.     /*                    Setters and Getters                                                                      */
  103.     /*--------------------------------------------------------------------------------------------------------*/
  104.     /**
  105.      * Get id.
  106.      *
  107.      * @return int
  108.      */
  109.     public function getId()
  110.     {
  111.         return $this->id;
  112.     }
  113.     /**
  114.      * Set amount.
  115.      *
  116.      * @param string $amount
  117.      *
  118.      * @return UserAdjustedTokenEntity
  119.      */
  120.     public function setAmount($amount)
  121.     {
  122.         $this->amount $amount;
  123.         return $this;
  124.     }
  125.     /**
  126.      * Get amount.
  127.      *
  128.      * @return string
  129.      */
  130.     public function getAmount()
  131.     {
  132.         return $this->amount;
  133.     }
  134.     /**
  135.      * Set createdBy.
  136.      *
  137.      * @param string $createdBy
  138.      *
  139.      * @return UserAdjustedTokenEntity
  140.      */
  141.     public function setCreatedBy($createdBy)
  142.     {
  143.         $this->createdBy $createdBy;
  144.         return $this;
  145.     }
  146.     /**
  147.      * Get createdBy.
  148.      *
  149.      * @return string
  150.      */
  151.     public function getCreatedBy()
  152.     {
  153.         return $this->createdBy;
  154.     }
  155.     /**
  156.      * Set createdAt.
  157.      *
  158.      * @param \DateTime $createdAt
  159.      *
  160.      * @return UserAdjustedTokenEntity
  161.      */
  162.     public function setCreatedAt($createdAt)
  163.     {
  164.         $this->createdAt $createdAt;
  165.         return $this;
  166.     }
  167.     /**
  168.      * Get createdAt.
  169.      *
  170.      * @return \DateTime
  171.      */
  172.     public function getCreatedAt()
  173.     {
  174.         return $this->createdAt;
  175.     }
  176.     /**
  177.      * Set updatedBy.
  178.      *
  179.      * @param string $updatedBy
  180.      *
  181.      * @return UserAdjustedTokenEntity
  182.      */
  183.     public function setUpdatedBy($updatedBy)
  184.     {
  185.         $this->updatedBy $updatedBy;
  186.         return $this;
  187.     }
  188.     /**
  189.      * Get updatedBy.
  190.      *
  191.      * @return string
  192.      */
  193.     public function getUpdatedBy()
  194.     {
  195.         return $this->updatedBy;
  196.     }
  197.     /**
  198.      * Set updatedAt.
  199.      *
  200.      * @param \DateTime $updatedAt
  201.      *
  202.      * @return UserAdjustedTokenEntity
  203.      */
  204.     public function setUpdatedAt($updatedAt)
  205.     {
  206.         $this->updatedAt $updatedAt;
  207.         return $this;
  208.     }
  209.     /**
  210.      * Get updatedAt.
  211.      *
  212.      * @return \DateTime
  213.      */
  214.     public function getUpdatedAt()
  215.     {
  216.         return $this->updatedAt;
  217.     }
  218.     /**
  219.      * Set user.
  220.      *
  221.      * @param \App\Entity\UserEntity|null $user
  222.      *
  223.      * @return UserAdjustedTokenEntity
  224.      */
  225.     public function setUser(\App\Entity\UserEntity $user null)
  226.     {
  227.         $this->user $user;
  228.         return $this;
  229.     }
  230.     /**
  231.      * Get user.
  232.      *
  233.      * @return \App\Entity\UserEntity|null
  234.      */
  235.     public function getUser()
  236.     {
  237.         return $this->user;
  238.     }
  239.     
  240.     /**
  241.  * @ORM\Column(type="string", length=100, nullable=true)
  242.  */
  243. protected $reason;
  244. public function getReason(): ?string
  245. {
  246.     return $this->reason;
  247. }
  248. public function setReason(?string $reason): self
  249. {
  250.     $this->reason $reason;
  251.     return $this;
  252. }
  253. }