src/AppBundle/AdminBundle/Entity/AdminNotifications.php line 335

Open in your IDE?
  1. <?php
  2. namespace App\AppBundle\AdminBundle\Entity;
  3. use App\AppBundle\MainBundle\Entity\User;
  4. use DateTime;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use JsonSerializable;
  9. /**
  10.  * AddOns
  11.  *
  12.  * @ORM\Entity
  13.  * @ORM\Table(name="admin_notifications")
  14.  * @ORM\HasLifecycleCallbacks()
  15.  */
  16. class AdminNotifications implements JsonSerializable
  17. {
  18.     const
  19.         TYPE_NEW_USER_REGISTERED 'new_user_registered',//Done
  20.         TYPE_NEW_VERIFY_SPOT_REQUEST 'new_verify_spot_request',//Done
  21.         TYPE_NEW_SPOT_CREATED 'new_spot_created',//Done
  22.         TYPE_NEW_BOOKING_HOURLY 'new_booking_hourly',//Done
  23.         TYPE_NEW_BOOKING_FLEXIBLE 'new_booking_flexible',//Done
  24.         TYPE_NEW_BOOKING_MONTHLY 'new_booking_monthly',//Done
  25.         TYPE_CANCEL_BOOKING_HOURLY 'cancel_booking_hourly',//Done
  26.         TYPE_CANCEL_BOOKING_FLEXIBLE 'cancel_booking_flexible',//Done
  27.         TYPE_CANCEL_BOOKING_MONTHLY 'cancel_booking_monthly',//Done
  28.         TYPE_SPOT_ACTIVATED 'spot_activated',//Done
  29.         TYPE_SPOT_DEACTIVATED 'spot_deactivated',//Done
  30.         TYPE_SPOT_DELETED 'spot_deleted',//Done
  31.         TYPE_INCOMPLETE_SPOT_DELETED 'incomplete_spot_deleted',//Done
  32.         TYPE_PAYOUT_PROCESSED 'payout_processed',
  33.         TYPE_PAYOUT_REQUESTED 'payout_requested',
  34.         TYPE_HELP_BUG_REPORTED 'help_bug_reported',//Done
  35.         TYPE_HELP_NEW_IDEA_REPORTED 'help_new_idea_reported',//Done
  36.         TYPE_HELP_CALL_BACK_REQUESTED 'help_call_back_requested',//Done
  37.         TYPE_HELP_MESSAGE_RECEIVED 'help_message_received',//Done
  38.         TYPE_OTHER 'other';
  39.     const TITLE = [
  40.         self::TYPE_NEW_USER_REGISTERED => 'admin.notification.title.new.user.registered',
  41.         self::TYPE_NEW_VERIFY_SPOT_REQUEST => 'admin.notification.title.new.verify.spot.request',
  42.         self::TYPE_NEW_SPOT_CREATED => 'admin.notification.title.new.spot.created',
  43.         self::TYPE_NEW_BOOKING_HOURLY => 'admin.notification.title.new.booking.hourly',
  44.         self::TYPE_NEW_BOOKING_FLEXIBLE => 'admin.notification.title.new.booking.flexible',
  45.         self::TYPE_NEW_BOOKING_MONTHLY => 'admin.notification.title.new.booking.monthly',
  46.         self::TYPE_CANCEL_BOOKING_HOURLY => 'admin.notification.title.cancel.booking.hourly',
  47.         self::TYPE_CANCEL_BOOKING_FLEXIBLE => 'admin.notification.title.cancel.booking.flexible',
  48.         self::TYPE_CANCEL_BOOKING_MONTHLY =>'admin.notification.title.cancel.booking.monthly',
  49.         self::TYPE_SPOT_ACTIVATED => 'admin.notification.title.spot.activated',
  50.         self::TYPE_SPOT_DEACTIVATED => 'admin.notification.title.spot.deactivated',
  51.         self::TYPE_SPOT_DELETED => 'admin.notification.title.spot.deleted',
  52.         self::TYPE_INCOMPLETE_SPOT_DELETED => 'admin.notification.title.incomplete.spot.deleted',
  53.         self::TYPE_PAYOUT_PROCESSED => 'admin.notification.title.payout.processed',
  54.         self::TYPE_PAYOUT_REQUESTED => 'admin.notification.title.payout.requested',
  55.         self::TYPE_HELP_BUG_REPORTED => 'admin.notification.title.help.bug.reported',
  56.         self::TYPE_HELP_NEW_IDEA_REPORTED => 'admin.notification.title.help.new.idea.reported',
  57.         self::TYPE_HELP_CALL_BACK_REQUESTED => 'admin.notification.title.help.call.back.requested',
  58.         self::TYPE_HELP_MESSAGE_RECEIVED => 'admin.notification.title.help.message.received',
  59.         self::TYPE_OTHER => 'admin.notification.title.other'
  60.     ];
  61.     const MESSAGE = [
  62.         self::TYPE_NEW_USER_REGISTERED => 'admin.notification.message.new.user.registered',
  63.         self::TYPE_NEW_VERIFY_SPOT_REQUEST => 'admin.notification.message.new.verify.spot.request',
  64.         self::TYPE_NEW_SPOT_CREATED => 'admin.notification.message.new.spot.created',
  65.         self::TYPE_NEW_BOOKING_HOURLY => 'admin.notification.message.new.booking.hourly',
  66.         self::TYPE_NEW_BOOKING_FLEXIBLE => 'admin.notification.message.new.booking.flexible',
  67.         self::TYPE_NEW_BOOKING_MONTHLY => 'admin.notification.message.new.booking.monthly',
  68.         self::TYPE_CANCEL_BOOKING_HOURLY => 'admin.notification.message.cancel.booking.hourly',
  69.         self::TYPE_CANCEL_BOOKING_FLEXIBLE => 'admin.notification.message.cancel.booking.flexible',
  70.         self::TYPE_CANCEL_BOOKING_MONTHLY =>'admin.notification.message.cancel.booking.monthly',
  71.         self::TYPE_SPOT_ACTIVATED => 'admin.notification.message.spot.activated',
  72.         self::TYPE_SPOT_DEACTIVATED => 'admin.notification.message.spot.deactivated',
  73.         self::TYPE_SPOT_DELETED => 'admin.notification.message.spot.deleted',
  74.         self::TYPE_INCOMPLETE_SPOT_DELETED => 'admin.notification.message.incomplete.spot.deleted',
  75.         self::TYPE_PAYOUT_PROCESSED => 'admin.notification.message.payout.processed',
  76.         self::TYPE_PAYOUT_REQUESTED => 'admin.notification.message.payout.requested',
  77.         self::TYPE_HELP_BUG_REPORTED => 'admin.notification.message.help.bug.reported',
  78.         self::TYPE_HELP_NEW_IDEA_REPORTED => 'admin.notification.message.help.new.idea.reported',
  79.         self::TYPE_HELP_CALL_BACK_REQUESTED => 'admin.notification.message.help.call.back.requested',
  80.         self::TYPE_HELP_MESSAGE_RECEIVED => 'admin.notification.message.help.message.received',
  81.         self::TYPE_OTHER => 'admin.notification.message.other'
  82.     ];
  83.     /**
  84.      * @ORM\Column(type="integer")
  85.      * @ORM\Id
  86.      * @ORM\GeneratedValue(strategy="AUTO")
  87.      */
  88.     private $id;
  89.     /**
  90.      * @var User
  91.      * @ORM\ManyToOne(targetEntity="App\AppBundle\MainBundle\Entity\User")
  92.      * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
  93.      */
  94.     private $user;
  95.     /**
  96.      * @var string
  97.      * @ORM\Column(type="string", nullable=false)
  98.      * @Assert\NotBlank()
  99.      */
  100.     private $type;
  101.     /**
  102.      * @var string
  103.      * @ORM\Column(type="string", nullable=true, length=1024)
  104.      * @Assert\NotBlank()
  105.      */
  106.     private $image;
  107.     /**
  108.      * @var string
  109.      * @ORM\Column(type="string", nullable=false)
  110.      * @Assert\NotBlank()
  111.      */
  112.     private $title;
  113.     /**
  114.      * @var string
  115.      * @ORM\Column(type="string", nullable=false, length=1024)
  116.      * @Assert\NotBlank()
  117.      */
  118.     private $message;
  119.     /**
  120.      * @var string
  121.      * @ORM\Column(type="string", nullable=true)
  122.      * @Assert\NotBlank()
  123.      */
  124.     private $payload;
  125.     /**
  126.      * @var boolean
  127.      * @ORM\Column(type="boolean", nullable=false)
  128.      * @Assert\NotBlank()
  129.      */
  130.     private $seen 0;
  131.     /**
  132.      * @var boolean
  133.      * @ORM\Column(type="boolean", nullable=false)
  134.      * @Assert\NotBlank()
  135.      */
  136.     private $active 1;
  137.     /**
  138.      * @return mixed
  139.      */
  140.     public function getId()
  141.     {
  142.         return $this->id;
  143.     }
  144.     /**
  145.      * @return User
  146.      */
  147.     public function getUser()
  148.     {
  149.         return $this->user;
  150.     }
  151.     /**
  152.      * @param User $user
  153.      */
  154.     public function setUser(User $user)
  155.     {
  156.         $this->user $user;
  157.     }
  158.     /**
  159.      * @return string
  160.      */
  161.     public function getType()
  162.     {
  163.         return $this->type;
  164.     }
  165.     /**
  166.      * @param string $type
  167.      */
  168.     public function setType(string $type)
  169.     {
  170.         $this->type $type;
  171.     }
  172.     /**
  173.      * @return string
  174.      */
  175.     public function getImage()
  176.     {
  177.         return $this->image;
  178.     }
  179.     /**
  180.      * @param string $image
  181.      */
  182.     public function setImage(string $image)
  183.     {
  184.         $this->image $image;
  185.     }
  186.     /**
  187.      * @return string
  188.      */
  189.     public function getTitle()
  190.     {
  191.         return $this->title;
  192.     }
  193.     /**
  194.      * @param string $title
  195.      */
  196.     public function setTitle(string $title)
  197.     {
  198.         $this->title $title;
  199.     }
  200.     /**
  201.      * @return string
  202.      */
  203.     public function getMessage()
  204.     {
  205.         return $this->message;
  206.     }
  207.     /**
  208.      * @param string $message
  209.      */
  210.     public function setMessage(string $message)
  211.     {
  212.         $this->message $message;
  213.     }
  214.     /**
  215.      * @return string
  216.      */
  217.     public function getPayload()
  218.     {
  219.         return $this->payload;
  220.     }
  221.     /**
  222.      * @param array $payload
  223.      * @return string
  224.      */
  225.     public function setPayload($payload)
  226.     {
  227.         $this->payload json_encode($payload);
  228.         return $this;
  229.     }
  230.     /**
  231.      * @return bool
  232.      */
  233.     public function isSeen()
  234.     {
  235.         return $this->seen;
  236.     }
  237.     /**
  238.      * @param bool $seen
  239.      */
  240.     public function setSeen(bool $seen)
  241.     {
  242.         $this->seen $seen;
  243.     }
  244.     /**
  245.      * @return bool
  246.      */
  247.     public function isActive()
  248.     {
  249.         return $this->active;
  250.     }
  251.     /**
  252.      * @param bool $active
  253.      */
  254.     public function setActive(bool $active)
  255.     {
  256.         $this->active $active;
  257.     }
  258.     public function jsonSerialize()
  259.     {
  260.         return array(
  261.             'id' => $this->id,
  262.             'user' => $this->user,
  263.             'active' => $this->active,
  264.             'image' => $this->image,
  265.             'title' => $this->title,
  266.             'type' => $this->type,
  267.             'message' => $this->message,
  268.             'seen' => $this->seen,
  269.             'payload' => $this->payload,
  270.             'createdAt' => $this->createdAt->format('Y-m-d H:i:s'),
  271.             'updatedAt' => $this->updatedAt->format('Y-m-d H:i:s'),
  272.         );
  273.     }
  274.     /**
  275.      * @var DateTime $created
  276.      *
  277.      * @ORM\Column(type="datetime", nullable=false)
  278.      */
  279.     protected $createdAt;
  280.     /**
  281.      * @var DateTime $updated
  282.      *
  283.      * @ORM\Column(type="datetime", nullable=false)
  284.      */
  285.     protected $updatedAt;
  286.     /**
  287.      * @return DateTime
  288.      */
  289.     public function getCreatedAt()
  290.     {
  291.         return $this->createdAt;
  292.     }
  293.     /**
  294.      * @return DateTime
  295.      */
  296.     public function getUpdatedAt()
  297.     {
  298.         return $this->updatedAt;
  299.     }
  300.     public function setUpdatedAt($updatedAt)
  301.     {
  302.         $this->updatedAt $updatedAt;
  303.         return $this;
  304.     }
  305.     /**
  306.      * @ORM\PrePersist
  307.      */
  308.     public function setCreatedAt()
  309.     {
  310.         $this->createdAt = new DateTime();
  311.         $this->updatedAt = new DateTime();
  312.         return $this;
  313.     }
  314.     /**
  315.      * @ORM\PreUpdate
  316.      */
  317.     public function setUpdatedAtValue() {
  318.         $this->updatedAt = new DateTime();
  319.     }
  320.     public function __construct() {
  321.     }
  322. }