src/AppBundle/MainBundle/Entity/UserNotifications.php line 426

Open in your IDE?
  1. <?php
  2. namespace App\AppBundle\MainBundle\Entity;
  3. use DateTime;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. use JsonSerializable;
  8. /**
  9.  * AddOns
  10.  *
  11.  * @ORM\Entity(repositoryClass="App\AppBundle\MainBundle\Repository\UserNotificationsRepository")
  12.  * @ORM\Table(name="user_notifications")
  13.  * @ORM\HasLifecycleCallbacks()
  14.  */
  15. class UserNotifications implements JsonSerializable
  16. {
  17.     //ss - spot seeker
  18.     //su - spot user
  19.     const
  20.         TYPE_SPOT_VERIFIED_CONFIRMATION 'sp_spot_verified_confirmation',
  21.         TYPE_SPOT_VALIDATED_CONFIRMATION 'sp_spot_validated_confirmation',
  22.         TYPE_SPOT_ERROR 'sp_spot_error',
  23.         TYPE_NEW_RESERVATION_HOURLY 'sp_new_reservation_hourly',//Done
  24.         TYPE_NEW_RESERVATION_FLEXIBLE 'sp_new_reservation_flexible',//Done
  25.         TYPE_NEW_RESERVATION_MONTHLY 'sp_new_reservation_monthly',//Done
  26.         TYPE_BOOKING_HOURLY_UPCOMING 'su_booking_hourly_upcoming',//Done
  27.         TYPE_BOOKING_HOURLY_STARTED 'su_booking_hourly_started',//Done
  28.         TYPE_BOOKING_HOURLY_EXTEND 'su_booking_hourly_extend',//Done - Hourly Extend Booking Reminder
  29.         TYPE_BOOKING_HOURLY_COMPLETED 'su_booking_hourly_completed',//Done
  30.         TYPE_BOOKING_FLEXIBLE_UPCOMING 'su_booking_flexible_upcoming',//Done
  31.         TYPE_BOOKING_FLEXIBLE_STARTED 'su_booking_flexible_started',//Done
  32.         TYPE_BOOKING_FLEXIBLE_COMPLETED 'su_booking_flexible_completed',//Done
  33.         TYPE_BOOKING_MONTHLY_UPCOMING 'su_booking_monthly_upcoming',
  34.         TYPE_BOOKING_MONTHLY_STARTED 'su_booking_monthly_started',
  35.         TYPE_BOOKING_MONTHLY_COMPLETED 'su_booking_monthly_completed',
  36.         TYPE_BOOKING_MONTHLY_RENEWAL_DUE 'su_booking_monthly_renewal_due',
  37.         TYPE_BOOKING_MONTHLY_RENEWED 'su_booking_monthly_renewed',//Done
  38.         TYPE_BOOKING_MONTHLY_RENEWED_FAILED 'su_booking_monthly_renewed_failed',//Done
  39.         TYPE_CANCEL_BOOKING_HOURLY 'su_cancel_booking_hourly',
  40.         TYPE_CANCEL_BOOKING_FLEXIBLE 'su_cancel_booking_flexible',
  41.         TYPE_CANCEL_BOOKING_MONTHLY 'su_cancel_booking_monthly',
  42.         TYPE_CANCEL_RESERVATION_HOURLY 'sp_cancel_reservation_hourly',
  43.         TYPE_CANCEL_RESERVATION_FLEXIBLE 'sp_cancel_reservation_flexible',
  44.         TYPE_CANCEL_RESERVATION_MONTHLY 'sp_cancel_reservation_monthly',
  45.         TYPE_SPOT_ACTIVATED 'sp_spot_activated',//Done
  46.         TYPE_SPOT_DEACTIVATED 'sp_spot_deactivated',//Done
  47.         TYPE_SPOT_DELETED 'sp_spot_deleted',//Done
  48.         TYPE_RATE_SPOT 'su_rate_spot',//Done
  49.         TYPE_NEW_SPOT_RATING 'sp_new_spot_rating',//Done
  50.         TYPE_STATEMENT_GENERATED 'sp_statement_generated',
  51.         TYPE_PAYOUT_PROCESSED 'sp_payout_processed',
  52.         TYPE_SYSTEM_PROMO 'system_promo',
  53.         TYPE_WELCOME_USER 'su_sp_welcome_user',//Done
  54.         TYPE_SYSTEM_NEW_CHAT_MESSAGE 'system_new_chat_message',
  55.         TYPE_REFERRAL_CODE_REDEEM 'referral_code_redeem',
  56.         TYPE_OTHER 'other';
  57.     const TITLE = [
  58.         self::TYPE_SPOT_VERIFIED_CONFIRMATION => 'notification.title.sp.spot.verified.confirmation',
  59.         self::TYPE_SPOT_VALIDATED_CONFIRMATION => 'notification.title.sp.spot.validated.confirmation',
  60.         self::TYPE_SPOT_ERROR => 'notification.title.sp.spot.error',
  61.         self::TYPE_NEW_RESERVATION_HOURLY => 'notification.title.sp.new.reservation.hourly',
  62.         self::TYPE_NEW_RESERVATION_FLEXIBLE => 'notification.title.sp.new.reservation.flexible',
  63.         self::TYPE_NEW_RESERVATION_MONTHLY => 'notification.title.sp.new.reservation.monthly',
  64.         self::TYPE_BOOKING_HOURLY_UPCOMING => 'notification.title.su.booking.hourly.upcoming',
  65.         self::TYPE_BOOKING_HOURLY_STARTED => 'notification.title.su.booking.hourly.started',
  66.         self::TYPE_BOOKING_HOURLY_EXTEND => 'notification.title.su.booking.hourly.extend',
  67.         self::TYPE_BOOKING_HOURLY_COMPLETED => 'notification.title.su.booking.hourly.completed',
  68.         self::TYPE_BOOKING_FLEXIBLE_UPCOMING => 'notification.title.su.booking.flexible.upcoming',
  69.         self::TYPE_BOOKING_FLEXIBLE_STARTED => 'notification.title.su.booking.flexible.started',
  70.         self::TYPE_BOOKING_FLEXIBLE_COMPLETED => 'notification.title.su.booking.flexible.completed',
  71.         self::TYPE_BOOKING_MONTHLY_UPCOMING => 'notification.title.su.booking.monthly.upcoming',
  72.         self::TYPE_BOOKING_MONTHLY_STARTED => 'notification.title.su.booking.monthly.started',
  73.         self::TYPE_BOOKING_MONTHLY_COMPLETED => 'notification.title.su.booking.monthly.completed',
  74.         self::TYPE_BOOKING_MONTHLY_RENEWAL_DUE => 'notification.title.su.booking.monthly.renewal.due',
  75.         self::TYPE_BOOKING_MONTHLY_RENEWED => 'notification.title.su.booking.monthly.renewed',
  76.         self::TYPE_BOOKING_MONTHLY_RENEWED_FAILED => 'notification.title.su.booking.monthly.renewed.failed',
  77.         self::TYPE_CANCEL_BOOKING_HOURLY => 'notification.title.su.cancel.booking.hourly',
  78.         self::TYPE_CANCEL_BOOKING_FLEXIBLE => 'notification.title.su.cancel.booking.flexible',
  79.         self::TYPE_CANCEL_BOOKING_MONTHLY => 'notification.title.su.cancel.booking.monthly',
  80.         self::TYPE_CANCEL_RESERVATION_HOURLY => 'notification.title.sp.cancel.reservation.hourly',
  81.         self::TYPE_CANCEL_RESERVATION_FLEXIBLE => 'notification.title.sp.cancel.reservation.flexible',
  82.         self::TYPE_CANCEL_RESERVATION_MONTHLY => 'notification.title.sp.cancel.reservation.monthly',
  83.         self::TYPE_SPOT_ACTIVATED => 'notification.title.sp.spot.activated',
  84.         self::TYPE_SPOT_DEACTIVATED => 'notification.title.sp.spot.deactivated',
  85.         self::TYPE_SPOT_DELETED => 'notification.title.sp.spot.deleted',
  86.         self::TYPE_RATE_SPOT => 'notification.title.su.rate.spot',
  87.         self::TYPE_NEW_SPOT_RATING => 'notification.title.sp.new.spot.rating',
  88.         self::TYPE_STATEMENT_GENERATED => 'notification.title.sp.statement.generated',
  89.         self::TYPE_PAYOUT_PROCESSED => 'notification.title.sp.payout.processed',
  90.         self::TYPE_SYSTEM_PROMO => 'notification.title.system.promo',
  91.         self::TYPE_WELCOME_USER => 'notification.title.welcome.user',
  92.         self::TYPE_SYSTEM_NEW_CHAT_MESSAGE => 'notification.title.system.new.chat.message',
  93.         self::TYPE_REFERRAL_CODE_REDEEM => 'notification.title.referral.code.redeem.title',
  94.         self::TYPE_OTHER => 'notification.title.other'
  95.     ];
  96.     const MESSAGE = [
  97.         self::TYPE_SPOT_VERIFIED_CONFIRMATION => 'notification.message.sp.spot.verified.confirmation',
  98.         self::TYPE_SPOT_VALIDATED_CONFIRMATION => 'notification.message.sp.spot.validated.confirmation',
  99.         self::TYPE_SPOT_ERROR => 'notification.message.sp.spot.error',
  100.         self::TYPE_NEW_RESERVATION_HOURLY => 'notification.message.sp.new.reservation.hourly',
  101.         self::TYPE_NEW_RESERVATION_FLEXIBLE => 'notification.message.sp.new.reservation.flexible',
  102.         self::TYPE_NEW_RESERVATION_MONTHLY => 'notification.message.sp.new.reservation.monthly',
  103.         self::TYPE_BOOKING_HOURLY_UPCOMING => 'notification.message.su.booking.hourly.upcoming',
  104.         self::TYPE_BOOKING_HOURLY_STARTED => 'notification.message.su.booking.hourly.started',
  105.         self::TYPE_BOOKING_HOURLY_EXTEND => 'notification.message.su.booking.hourly.extend',
  106.         self::TYPE_BOOKING_HOURLY_COMPLETED => 'notification.message.su.booking.hourly.completed',
  107.         self::TYPE_BOOKING_FLEXIBLE_UPCOMING => 'notification.message.su.booking.flexible.upcoming',
  108.         self::TYPE_BOOKING_FLEXIBLE_STARTED => 'notification.message.su.booking.flexible.started',
  109.         self::TYPE_BOOKING_FLEXIBLE_COMPLETED => 'notification.message.su.booking.flexible.completed',
  110.         self::TYPE_BOOKING_MONTHLY_UPCOMING => 'notification.message.su.booking.monthly.upcoming',
  111.         self::TYPE_BOOKING_MONTHLY_STARTED => 'notification.message.su.booking.monthly.started',
  112.         self::TYPE_BOOKING_MONTHLY_COMPLETED => 'notification.message.su.booking.monthly.completed',
  113.         self::TYPE_BOOKING_MONTHLY_RENEWAL_DUE => 'notification.message.su.booking.monthly.renewal.due',
  114.         self::TYPE_BOOKING_MONTHLY_RENEWED => 'notification.message.su.booking.monthly.renewed',
  115.         self::TYPE_BOOKING_MONTHLY_RENEWED_FAILED => 'notification.message.su.booking.monthly.renewed.failed',
  116.         self::TYPE_CANCEL_BOOKING_HOURLY => 'notification.message.su.cancel.booking.hourly',
  117.         self::TYPE_CANCEL_BOOKING_FLEXIBLE => 'notification.message.su.cancel.booking.flexible',
  118.         self::TYPE_CANCEL_BOOKING_MONTHLY => 'notification.message.su.cancel.booking.monthly',
  119.         self::TYPE_CANCEL_RESERVATION_HOURLY => 'notification.message.sp.cancel.reservation.hourly',
  120.         self::TYPE_CANCEL_RESERVATION_FLEXIBLE => 'notification.message.sp.cancel.reservation.flexible',
  121.         self::TYPE_CANCEL_RESERVATION_MONTHLY => 'notification.message.sp.cancel.reservation.monthly',
  122.         self::TYPE_SPOT_ACTIVATED => 'notification.message.sp.spot.activated',
  123.         self::TYPE_SPOT_DEACTIVATED => 'notification.message.sp.spot.deactivated',
  124.         self::TYPE_SPOT_DELETED => 'notification.message.sp.spot.deleted',
  125.         self::TYPE_RATE_SPOT => 'notification.message.su.rate.spot',
  126.         self::TYPE_NEW_SPOT_RATING => 'notification.message.sp.new.spot.rating',
  127.         self::TYPE_STATEMENT_GENERATED => 'notification.message.sp.statement.generated',
  128.         self::TYPE_PAYOUT_PROCESSED => 'notification.message.sp.payout.processed',
  129.         self::TYPE_SYSTEM_PROMO => 'notification.message.system.promo',
  130.         self::TYPE_WELCOME_USER => 'notification.message.welcome.user',
  131.         self::TYPE_SYSTEM_NEW_CHAT_MESSAGE => 'notification.message.system.new.chat.message',
  132.         self::TYPE_REFERRAL_CODE_REDEEM => 'notification.title.referral.code.redeem.message',
  133.         self::TYPE_OTHER => 'notification.message.other'
  134.     ];
  135.     /**
  136.      * @ORM\Column(type="integer")
  137.      * @ORM\Id
  138.      * @ORM\GeneratedValue(strategy="AUTO")
  139.      */
  140.     private $id;
  141.     /**
  142.      * @var User
  143.      * @ORM\ManyToOne(targetEntity="User")
  144.      * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
  145.      */
  146.     private $user;
  147.     /**
  148.      * @var string
  149.      * @ORM\Column(type="string", nullable=false)
  150.      */
  151.     private $type;
  152.     /**
  153.      * @var string
  154.      * @ORM\Column(type="string", nullable=true, length=1024)
  155.      */
  156.     private $image;
  157.     /**
  158.      * @var string
  159.      * @ORM\Column(type="string", nullable=false)
  160.      */
  161.     private $title;
  162.     /**
  163.      * @var string
  164.      * @ORM\Column(type="string", nullable=false, length=1024)
  165.      */
  166.     private $message;
  167.     /**
  168.      * @var string
  169.      * @ORM\Column(type="string", nullable=true)
  170.      */
  171.     private $payload;
  172.     /**
  173.      * @var boolean
  174.      * @ORM\Column(type="boolean", nullable=false)
  175.      */
  176.     private $seen 0;
  177.     /**
  178.      * @var boolean
  179.      * @ORM\Column(type="boolean", nullable=false)
  180.      */
  181.     private $active 1;
  182.     /**
  183.      * @var string
  184.      * @ORM\Column(type="string", nullable=true)
  185.      */
  186.     private $promo_code;
  187.     /**
  188.      * @return mixed
  189.      */
  190.     public function getId()
  191.     {
  192.         return $this->id;
  193.     }
  194.     /**
  195.      * @return User
  196.      */
  197.     public function getUser()
  198.     {
  199.         return $this->user;
  200.     }
  201.     /**
  202.      * @param User $user
  203.      */
  204.     public function setUser(User $user)
  205.     {
  206.         $this->user $user;
  207.     }
  208.     /**
  209.      * @return string
  210.      */
  211.     public function getType()
  212.     {
  213.         return $this->type;
  214.     }
  215.     /**
  216.      * @param string $type
  217.      */
  218.     public function setType($type)
  219.     {
  220.         $this->type $type;
  221.     }
  222.     /**
  223.      * @return string
  224.      */
  225.     public function getImage()
  226.     {
  227.         return $this->image;
  228.     }
  229.     /**
  230.      * @param string $image
  231.      */
  232.     public function setImage($image)
  233.     {
  234.         $this->image $image;
  235.     }
  236.     /**
  237.      * @return string
  238.      */
  239.     public function getTitle()
  240.     {
  241.         return $this->title;
  242.     }
  243.     /**
  244.      * @param string $title
  245.      */
  246.     public function setTitle($title)
  247.     {
  248.         $this->title $title;
  249.     }
  250.     /**
  251.      * @return string
  252.      */
  253.     public function getMessage()
  254.     {
  255.         return $this->message;
  256.     }
  257.     /**
  258.      * @param string $message
  259.      */
  260.     public function setMessage($message)
  261.     {
  262.         $this->message $message;
  263.     }
  264.     /**
  265.      * @return string
  266.      */
  267.     public function getPayload()
  268.     {
  269.         return $this->payload;
  270.     }
  271.     /**
  272.      * @return string
  273.      */
  274.     public function getPayloadJsonDecoded()
  275.     {
  276.         return json_decode($this->payloadtrue);
  277.     }
  278.     /**
  279.      * @param array $payload
  280.      * @return string
  281.      */
  282.     public function setPayload($payload)
  283.     {
  284.         $this->payload json_encode($payload);
  285.         return $this;
  286.     }
  287.     /**
  288.      * @return bool
  289.      */
  290.     public function isSeen()
  291.     {
  292.         return $this->seen;
  293.     }
  294.     /**
  295.      * @param bool $seen
  296.      */
  297.     public function setSeen($seen)
  298.     {
  299.         $this->seen $seen;
  300.     }
  301.     /**
  302.      * @return bool
  303.      */
  304.     public function isActive()
  305.     {
  306.         return $this->active;
  307.     }
  308.     /**
  309.      * @param bool $active
  310.      */
  311.     public function setActive($active)
  312.     {
  313.         $this->active $active;
  314.     }
  315.     /**
  316.      * @return string
  317.      */
  318.     public function getPromoCode()
  319.     {
  320.         return $this->promo_code;
  321.     }
  322.     /**
  323.      * @param string $promo_code
  324.      */
  325.     public function setPromoCode($promo_code)
  326.     {
  327.         $this->promo_code $promo_code;
  328.     }
  329.     public function jsonSerialize()
  330.     {
  331.         return array(
  332.             'id' => $this->id,
  333.             'user_id' => $this->getUser()->getId(),
  334.             'user_first_name' => $this->getUser()->getFirstName(),
  335.             'user_last_name' => $this->getUser()->getLastName(),
  336. //            'user_email' => $this->getUser()->getEmail(),
  337.             'active' => $this->active,
  338.             'image' => $this->image,
  339.             'title' => $this->title,
  340.             'type' => $this->type,
  341.             'message' => $this->message,
  342.             'seen' => $this->seen,
  343.             'promo_code' => $this->promo_code,
  344.             'payload' => $this->getPayloadJsonDecoded(),
  345.             'createdAt' => $this->createdAt->format('Y-m-d H:i:s'),
  346.             'updatedAt' => $this->updatedAt->format('Y-m-d H:i:s'),
  347.         );
  348.     }
  349.     /**
  350.      * @var DateTime $created
  351.      *
  352.      * @ORM\Column(type="datetime", nullable=false)
  353.      */
  354.     protected $createdAt;
  355.     /**
  356.      * @var DateTime $updated
  357.      *
  358.      * @ORM\Column(type="datetime", nullable=false)
  359.      */
  360.     protected $updatedAt;
  361.     /**
  362.      * @return DateTime
  363.      */
  364.     public function getCreatedAt()
  365.     {
  366.         return $this->createdAt;
  367.     }
  368.     /**
  369.      * @return DateTime
  370.      */
  371.     public function getUpdatedAt()
  372.     {
  373.         return $this->updatedAt;
  374.     }
  375.     public function setUpdatedAt($updatedAt)
  376.     {
  377.         $this->updatedAt $updatedAt;
  378.         return $this;
  379.     }
  380.     /**
  381.      * @ORM\PrePersist
  382.      */
  383.     public function setCreatedAt()
  384.     {
  385.         $this->createdAt = new DateTime();
  386.         $this->updatedAt = new DateTime();
  387.         return $this;
  388.     }
  389.     /**
  390.      * @ORM\PreUpdate
  391.      */
  392.     public function setUpdatedAtValue() {
  393.         $this->updatedAt = new DateTime();
  394.     }
  395.     public function __construct() {
  396.     }
  397. }