src/Entity/NotificationEntity.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\NotificationRepository")
  9.  * @ORM\Table(name="notification")
  10.  * @ORM\HasLifecycleCallbacks()
  11.  */
  12. class NotificationEntity
  13. {
  14.     /**
  15.      * @ORM\Column(type="bigint")
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue(strategy="AUTO")
  18.      */
  19.     protected $id;
  20.     /**
  21.      * @ORM\Column(type="string")
  22.      */
  23.     protected $type;
  24.     /**
  25.      * @ORM\Column(type="text")
  26.      */
  27.     protected $message;
  28.      /**
  29.      * @ORM\Column(name="status", type="string")
  30.      */
  31.     protected $status;
  32.     /**
  33.      * @ORM\Column(name="created_by", type="string", length=50)
  34.      */
  35.     protected $createdBy;
  36.     /**
  37.      * @ORM\Column(name="created_at", type="datetime")
  38.      */
  39.     protected $createdAt;
  40.     /**
  41.      * @ORM\Column(name="updated_by", type="string", length=50)
  42.      */
  43.     protected $updatedBy;
  44.     /**
  45.      * @ORM\Column(name="updated_at", type="datetime")
  46.      */
  47.     protected $updatedAt;
  48.      /**
  49.      * @ORM\ManyToOne(targetEntity="UserEntity", inversedBy="notifications")
  50.      * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
  51.      */
  52.     protected $user;
  53.     /**
  54.      * Set createdAt
  55.      *
  56.      * @ORM\PrePersist
  57.      */
  58.     public function setCreatedAtValue()
  59.     {
  60.         $this->createdBy = isset($_COOKIE['username']) ? $_COOKIE['username'] : 'System';
  61.         $this->createdAt = new \DateTime();
  62.         $this->updatedBy = isset($_COOKIE['username']) ? $_COOKIE['username'] : 'System';
  63.         $this->updatedAt = new \DateTime();
  64.         $this->status "New";
  65.     }
  66.     /**
  67.      * Set updatedAt
  68.      *
  69.      * @ORM\PreUpdate
  70.      */
  71.     public function setUpdatedAtValue()
  72.     {
  73.         $this->updatedBy = isset($_COOKIE['username']) ? $_COOKIE['username'] : 'System';
  74.         $this->updatedAt = new \DateTime();
  75.     }
  76.     public function __construct($data null)
  77.     {
  78.         if (!is_null($data)) {
  79.         }
  80.      
  81.     }
  82.     
  83.     /*--------------------------------------------------------------------------------------------------------*/
  84.     /*                        Defined Setters and Getters                                                          */
  85.     /*--------------------------------------------------------------------------------------------------------*/
  86.       /**
  87.      * Get idEncoded
  88.      *
  89.      * @return string
  90.      */
  91.     public function getIdEncoded() {
  92.         return base64_encode($this->id);
  93.     }
  94.      /**
  95.      * Get createdAtAsString
  96.      *
  97.      * @return string
  98.      */
  99.     public function getCreatedAtAsString()
  100.     {
  101.         $dttst = new DateTimeToStringTransformer();
  102.         return !empty($this->createdAt) ? date('m/d/Y'strtotime($dttst->transform($this->createdAt))) : '';
  103.     }
  104.     /**
  105.      * Get id.
  106.      *
  107.      * @return int
  108.      */
  109.     public function getId()
  110.     {
  111.         return $this->id;
  112.     }
  113.     /**
  114.      * Set message.
  115.      *
  116.      * @param string $message
  117.      *
  118.      * @return NotificationEntity
  119.      */
  120.     public function setMessage($message)
  121.     {
  122.         $this->message $message;
  123.         return $this;
  124.     }
  125.     /**
  126.      * Get message.
  127.      *
  128.      * @return string
  129.      */
  130.     public function getMessage()
  131.     {
  132.         return $this->message;
  133.     }
  134.     /**
  135.      * Set status.
  136.      *
  137.      * @param string $status
  138.      *
  139.      * @return NotificationEntity
  140.      */
  141.     public function setStatus($status)
  142.     {
  143.         $this->status $status;
  144.         return $this;
  145.     }
  146.     /**
  147.      * Get status.
  148.      *
  149.      * @return string
  150.      */
  151.     public function getStatus()
  152.     {
  153.         return $this->status;
  154.     }
  155.     /**
  156.      * Set createdBy.
  157.      *
  158.      * @param string $createdBy
  159.      *
  160.      * @return NotificationEntity
  161.      */
  162.     public function setCreatedBy($createdBy)
  163.     {
  164.         $this->createdBy $createdBy;
  165.         return $this;
  166.     }
  167.     /**
  168.      * Get createdBy.
  169.      *
  170.      * @return string
  171.      */
  172.     public function getCreatedBy()
  173.     {
  174.         return $this->createdBy;
  175.     }
  176.     /**
  177.      * Set createdAt.
  178.      *
  179.      * @param \DateTime $createdAt
  180.      *
  181.      * @return NotificationEntity
  182.      */
  183.     public function setCreatedAt($createdAt)
  184.     {
  185.         $this->createdAt $createdAt;
  186.         return $this;
  187.     }
  188.     /**
  189.      * Get createdAt.
  190.      *
  191.      * @return \DateTime
  192.      */
  193.     public function getCreatedAt()
  194.     {
  195.         return $this->createdAt;
  196.     }
  197.     /**
  198.      * Set updatedBy.
  199.      *
  200.      * @param string $updatedBy
  201.      *
  202.      * @return NotificationEntity
  203.      */
  204.     public function setUpdatedBy($updatedBy)
  205.     {
  206.         $this->updatedBy $updatedBy;
  207.         return $this;
  208.     }
  209.     /**
  210.      * Get updatedBy.
  211.      *
  212.      * @return string
  213.      */
  214.     public function getUpdatedBy()
  215.     {
  216.         return $this->updatedBy;
  217.     }
  218.     /**
  219.      * Set updatedAt.
  220.      *
  221.      * @param \DateTime $updatedAt
  222.      *
  223.      * @return NotificationEntity
  224.      */
  225.     public function setUpdatedAt($updatedAt)
  226.     {
  227.         $this->updatedAt $updatedAt;
  228.         return $this;
  229.     }
  230.     /**
  231.      * Get updatedAt.
  232.      *
  233.      * @return \DateTime
  234.      */
  235.     public function getUpdatedAt()
  236.     {
  237.         return $this->updatedAt;
  238.     }
  239.     /**
  240.      * Set user.
  241.      *
  242.      * @param \App\Entity\UserEntity|null $user
  243.      *
  244.      * @return NotificationEntity
  245.      */
  246.     public function setUser(\App\Entity\UserEntity $user null)
  247.     {
  248.         $this->user $user;
  249.         return $this;
  250.     }
  251.     /**
  252.      * Get user.
  253.      *
  254.      * @return \App\Entity\UserEntity|null
  255.      */
  256.     public function getUser()
  257.     {
  258.         return $this->user;
  259.     }
  260.     /**
  261.      * Set type.
  262.      *
  263.      * @param string $type
  264.      *
  265.      * @return NotificationEntity
  266.      */
  267.     public function setType($type)
  268.     {
  269.         $this->type $type;
  270.         return $this;
  271.     }
  272.     /**
  273.      * Get type.
  274.      *
  275.      * @return string
  276.      */
  277.     public function getType()
  278.     {
  279.         return $this->type;
  280.     }
  281. }