<?php
namespace App\AppBundle\MainBundle\Entity;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use JsonSerializable;
/**
* AddOns
*
* @ORM\Entity(repositoryClass="App\AppBundle\MainBundle\Repository\UserNotificationsRepository")
* @ORM\Table(name="user_notifications")
* @ORM\HasLifecycleCallbacks()
*/
class UserNotifications implements JsonSerializable
{
//ss - spot seeker
//su - spot user
const
TYPE_SPOT_VERIFIED_CONFIRMATION = 'sp_spot_verified_confirmation',
TYPE_SPOT_VALIDATED_CONFIRMATION = 'sp_spot_validated_confirmation',
TYPE_SPOT_ERROR = 'sp_spot_error',
TYPE_NEW_RESERVATION_HOURLY = 'sp_new_reservation_hourly',//Done
TYPE_NEW_RESERVATION_FLEXIBLE = 'sp_new_reservation_flexible',//Done
TYPE_NEW_RESERVATION_MONTHLY = 'sp_new_reservation_monthly',//Done
TYPE_BOOKING_HOURLY_UPCOMING = 'su_booking_hourly_upcoming',//Done
TYPE_BOOKING_HOURLY_STARTED = 'su_booking_hourly_started',//Done
TYPE_BOOKING_HOURLY_EXTEND = 'su_booking_hourly_extend',//Done - Hourly Extend Booking Reminder
TYPE_BOOKING_HOURLY_COMPLETED = 'su_booking_hourly_completed',//Done
TYPE_BOOKING_FLEXIBLE_UPCOMING = 'su_booking_flexible_upcoming',//Done
TYPE_BOOKING_FLEXIBLE_STARTED = 'su_booking_flexible_started',//Done
TYPE_BOOKING_FLEXIBLE_COMPLETED = 'su_booking_flexible_completed',//Done
TYPE_BOOKING_MONTHLY_UPCOMING = 'su_booking_monthly_upcoming',
TYPE_BOOKING_MONTHLY_STARTED = 'su_booking_monthly_started',
TYPE_BOOKING_MONTHLY_COMPLETED = 'su_booking_monthly_completed',
TYPE_BOOKING_MONTHLY_RENEWAL_DUE = 'su_booking_monthly_renewal_due',
TYPE_BOOKING_MONTHLY_RENEWED = 'su_booking_monthly_renewed',//Done
TYPE_BOOKING_MONTHLY_RENEWED_FAILED = 'su_booking_monthly_renewed_failed',//Done
TYPE_CANCEL_BOOKING_HOURLY = 'su_cancel_booking_hourly',
TYPE_CANCEL_BOOKING_FLEXIBLE = 'su_cancel_booking_flexible',
TYPE_CANCEL_BOOKING_MONTHLY = 'su_cancel_booking_monthly',
TYPE_CANCEL_RESERVATION_HOURLY = 'sp_cancel_reservation_hourly',
TYPE_CANCEL_RESERVATION_FLEXIBLE = 'sp_cancel_reservation_flexible',
TYPE_CANCEL_RESERVATION_MONTHLY = 'sp_cancel_reservation_monthly',
TYPE_SPOT_ACTIVATED = 'sp_spot_activated',//Done
TYPE_SPOT_DEACTIVATED = 'sp_spot_deactivated',//Done
TYPE_SPOT_DELETED = 'sp_spot_deleted',//Done
TYPE_RATE_SPOT = 'su_rate_spot',//Done
TYPE_NEW_SPOT_RATING = 'sp_new_spot_rating',//Done
TYPE_STATEMENT_GENERATED = 'sp_statement_generated',
TYPE_PAYOUT_PROCESSED = 'sp_payout_processed',
TYPE_SYSTEM_PROMO = 'system_promo',
TYPE_WELCOME_USER = 'su_sp_welcome_user',//Done
TYPE_SYSTEM_NEW_CHAT_MESSAGE = 'system_new_chat_message',
TYPE_REFERRAL_CODE_REDEEM = 'referral_code_redeem',
TYPE_OTHER = 'other';
const TITLE = [
self::TYPE_SPOT_VERIFIED_CONFIRMATION => 'notification.title.sp.spot.verified.confirmation',
self::TYPE_SPOT_VALIDATED_CONFIRMATION => 'notification.title.sp.spot.validated.confirmation',
self::TYPE_SPOT_ERROR => 'notification.title.sp.spot.error',
self::TYPE_NEW_RESERVATION_HOURLY => 'notification.title.sp.new.reservation.hourly',
self::TYPE_NEW_RESERVATION_FLEXIBLE => 'notification.title.sp.new.reservation.flexible',
self::TYPE_NEW_RESERVATION_MONTHLY => 'notification.title.sp.new.reservation.monthly',
self::TYPE_BOOKING_HOURLY_UPCOMING => 'notification.title.su.booking.hourly.upcoming',
self::TYPE_BOOKING_HOURLY_STARTED => 'notification.title.su.booking.hourly.started',
self::TYPE_BOOKING_HOURLY_EXTEND => 'notification.title.su.booking.hourly.extend',
self::TYPE_BOOKING_HOURLY_COMPLETED => 'notification.title.su.booking.hourly.completed',
self::TYPE_BOOKING_FLEXIBLE_UPCOMING => 'notification.title.su.booking.flexible.upcoming',
self::TYPE_BOOKING_FLEXIBLE_STARTED => 'notification.title.su.booking.flexible.started',
self::TYPE_BOOKING_FLEXIBLE_COMPLETED => 'notification.title.su.booking.flexible.completed',
self::TYPE_BOOKING_MONTHLY_UPCOMING => 'notification.title.su.booking.monthly.upcoming',
self::TYPE_BOOKING_MONTHLY_STARTED => 'notification.title.su.booking.monthly.started',
self::TYPE_BOOKING_MONTHLY_COMPLETED => 'notification.title.su.booking.monthly.completed',
self::TYPE_BOOKING_MONTHLY_RENEWAL_DUE => 'notification.title.su.booking.monthly.renewal.due',
self::TYPE_BOOKING_MONTHLY_RENEWED => 'notification.title.su.booking.monthly.renewed',
self::TYPE_BOOKING_MONTHLY_RENEWED_FAILED => 'notification.title.su.booking.monthly.renewed.failed',
self::TYPE_CANCEL_BOOKING_HOURLY => 'notification.title.su.cancel.booking.hourly',
self::TYPE_CANCEL_BOOKING_FLEXIBLE => 'notification.title.su.cancel.booking.flexible',
self::TYPE_CANCEL_BOOKING_MONTHLY => 'notification.title.su.cancel.booking.monthly',
self::TYPE_CANCEL_RESERVATION_HOURLY => 'notification.title.sp.cancel.reservation.hourly',
self::TYPE_CANCEL_RESERVATION_FLEXIBLE => 'notification.title.sp.cancel.reservation.flexible',
self::TYPE_CANCEL_RESERVATION_MONTHLY => 'notification.title.sp.cancel.reservation.monthly',
self::TYPE_SPOT_ACTIVATED => 'notification.title.sp.spot.activated',
self::TYPE_SPOT_DEACTIVATED => 'notification.title.sp.spot.deactivated',
self::TYPE_SPOT_DELETED => 'notification.title.sp.spot.deleted',
self::TYPE_RATE_SPOT => 'notification.title.su.rate.spot',
self::TYPE_NEW_SPOT_RATING => 'notification.title.sp.new.spot.rating',
self::TYPE_STATEMENT_GENERATED => 'notification.title.sp.statement.generated',
self::TYPE_PAYOUT_PROCESSED => 'notification.title.sp.payout.processed',
self::TYPE_SYSTEM_PROMO => 'notification.title.system.promo',
self::TYPE_WELCOME_USER => 'notification.title.welcome.user',
self::TYPE_SYSTEM_NEW_CHAT_MESSAGE => 'notification.title.system.new.chat.message',
self::TYPE_REFERRAL_CODE_REDEEM => 'notification.title.referral.code.redeem.title',
self::TYPE_OTHER => 'notification.title.other'
];
const MESSAGE = [
self::TYPE_SPOT_VERIFIED_CONFIRMATION => 'notification.message.sp.spot.verified.confirmation',
self::TYPE_SPOT_VALIDATED_CONFIRMATION => 'notification.message.sp.spot.validated.confirmation',
self::TYPE_SPOT_ERROR => 'notification.message.sp.spot.error',
self::TYPE_NEW_RESERVATION_HOURLY => 'notification.message.sp.new.reservation.hourly',
self::TYPE_NEW_RESERVATION_FLEXIBLE => 'notification.message.sp.new.reservation.flexible',
self::TYPE_NEW_RESERVATION_MONTHLY => 'notification.message.sp.new.reservation.monthly',
self::TYPE_BOOKING_HOURLY_UPCOMING => 'notification.message.su.booking.hourly.upcoming',
self::TYPE_BOOKING_HOURLY_STARTED => 'notification.message.su.booking.hourly.started',
self::TYPE_BOOKING_HOURLY_EXTEND => 'notification.message.su.booking.hourly.extend',
self::TYPE_BOOKING_HOURLY_COMPLETED => 'notification.message.su.booking.hourly.completed',
self::TYPE_BOOKING_FLEXIBLE_UPCOMING => 'notification.message.su.booking.flexible.upcoming',
self::TYPE_BOOKING_FLEXIBLE_STARTED => 'notification.message.su.booking.flexible.started',
self::TYPE_BOOKING_FLEXIBLE_COMPLETED => 'notification.message.su.booking.flexible.completed',
self::TYPE_BOOKING_MONTHLY_UPCOMING => 'notification.message.su.booking.monthly.upcoming',
self::TYPE_BOOKING_MONTHLY_STARTED => 'notification.message.su.booking.monthly.started',
self::TYPE_BOOKING_MONTHLY_COMPLETED => 'notification.message.su.booking.monthly.completed',
self::TYPE_BOOKING_MONTHLY_RENEWAL_DUE => 'notification.message.su.booking.monthly.renewal.due',
self::TYPE_BOOKING_MONTHLY_RENEWED => 'notification.message.su.booking.monthly.renewed',
self::TYPE_BOOKING_MONTHLY_RENEWED_FAILED => 'notification.message.su.booking.monthly.renewed.failed',
self::TYPE_CANCEL_BOOKING_HOURLY => 'notification.message.su.cancel.booking.hourly',
self::TYPE_CANCEL_BOOKING_FLEXIBLE => 'notification.message.su.cancel.booking.flexible',
self::TYPE_CANCEL_BOOKING_MONTHLY => 'notification.message.su.cancel.booking.monthly',
self::TYPE_CANCEL_RESERVATION_HOURLY => 'notification.message.sp.cancel.reservation.hourly',
self::TYPE_CANCEL_RESERVATION_FLEXIBLE => 'notification.message.sp.cancel.reservation.flexible',
self::TYPE_CANCEL_RESERVATION_MONTHLY => 'notification.message.sp.cancel.reservation.monthly',
self::TYPE_SPOT_ACTIVATED => 'notification.message.sp.spot.activated',
self::TYPE_SPOT_DEACTIVATED => 'notification.message.sp.spot.deactivated',
self::TYPE_SPOT_DELETED => 'notification.message.sp.spot.deleted',
self::TYPE_RATE_SPOT => 'notification.message.su.rate.spot',
self::TYPE_NEW_SPOT_RATING => 'notification.message.sp.new.spot.rating',
self::TYPE_STATEMENT_GENERATED => 'notification.message.sp.statement.generated',
self::TYPE_PAYOUT_PROCESSED => 'notification.message.sp.payout.processed',
self::TYPE_SYSTEM_PROMO => 'notification.message.system.promo',
self::TYPE_WELCOME_USER => 'notification.message.welcome.user',
self::TYPE_SYSTEM_NEW_CHAT_MESSAGE => 'notification.message.system.new.chat.message',
self::TYPE_REFERRAL_CODE_REDEEM => 'notification.title.referral.code.redeem.message',
self::TYPE_OTHER => 'notification.message.other'
];
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var User
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
private $user;
/**
* @var string
* @ORM\Column(type="string", nullable=false)
*/
private $type;
/**
* @var string
* @ORM\Column(type="string", nullable=true, length=1024)
*/
private $image;
/**
* @var string
* @ORM\Column(type="string", nullable=false)
*/
private $title;
/**
* @var string
* @ORM\Column(type="string", nullable=false, length=1024)
*/
private $message;
/**
* @var string
* @ORM\Column(type="string", nullable=true)
*/
private $payload;
/**
* @var boolean
* @ORM\Column(type="boolean", nullable=false)
*/
private $seen = 0;
/**
* @var boolean
* @ORM\Column(type="boolean", nullable=false)
*/
private $active = 1;
/**
* @var string
* @ORM\Column(type="string", nullable=true)
*/
private $promo_code;
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @return User
*/
public function getUser()
{
return $this->user;
}
/**
* @param User $user
*/
public function setUser(User $user)
{
$this->user = $user;
}
/**
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* @param string $type
*/
public function setType($type)
{
$this->type = $type;
}
/**
* @return string
*/
public function getImage()
{
return $this->image;
}
/**
* @param string $image
*/
public function setImage($image)
{
$this->image = $image;
}
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* @return string
*/
public function getMessage()
{
return $this->message;
}
/**
* @param string $message
*/
public function setMessage($message)
{
$this->message = $message;
}
/**
* @return string
*/
public function getPayload()
{
return $this->payload;
}
/**
* @return string
*/
public function getPayloadJsonDecoded()
{
return json_decode($this->payload, true);
}
/**
* @param array $payload
* @return string
*/
public function setPayload($payload)
{
$this->payload = json_encode($payload);
return $this;
}
/**
* @return bool
*/
public function isSeen()
{
return $this->seen;
}
/**
* @param bool $seen
*/
public function setSeen($seen)
{
$this->seen = $seen;
}
/**
* @return bool
*/
public function isActive()
{
return $this->active;
}
/**
* @param bool $active
*/
public function setActive($active)
{
$this->active = $active;
}
/**
* @return string
*/
public function getPromoCode()
{
return $this->promo_code;
}
/**
* @param string $promo_code
*/
public function setPromoCode($promo_code)
{
$this->promo_code = $promo_code;
}
public function jsonSerialize()
{
return array(
'id' => $this->id,
'user_id' => $this->getUser()->getId(),
'user_first_name' => $this->getUser()->getFirstName(),
'user_last_name' => $this->getUser()->getLastName(),
// 'user_email' => $this->getUser()->getEmail(),
'active' => $this->active,
'image' => $this->image,
'title' => $this->title,
'type' => $this->type,
'message' => $this->message,
'seen' => $this->seen,
'promo_code' => $this->promo_code,
'payload' => $this->getPayloadJsonDecoded(),
'createdAt' => $this->createdAt->format('Y-m-d H:i:s'),
'updatedAt' => $this->updatedAt->format('Y-m-d H:i:s'),
);
}
/**
* @var DateTime $created
*
* @ORM\Column(type="datetime", nullable=false)
*/
protected $createdAt;
/**
* @var DateTime $updated
*
* @ORM\Column(type="datetime", nullable=false)
*/
protected $updatedAt;
/**
* @return DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* @return DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @ORM\PrePersist
*/
public function setCreatedAt()
{
$this->createdAt = new DateTime();
$this->updatedAt = new DateTime();
return $this;
}
/**
* @ORM\PreUpdate
*/
public function setUpdatedAtValue() {
$this->updatedAt = new DateTime();
}
public function __construct() {
}
}