class Notification extends Model

A notification to a player

Traits

A timestamp column

Constants

TABLE

The name of the database table used for queries

Methods

static Notification
newNotification(int $receiver, string $type, Event $event, string $timestamp = 'now', string $status = 'unread')

Enter a new notification into the database

static Notification[]
getNotifications(int $receiver, bool $onlyUnread = false)

Show a list of notifications for a specific user

static int
countUnreadNotifications(int $receiver)

Show the number of notifications the user hasn't read yet

getReceiver()

Get the receiving player of the notification

int
getCategory()

Get the type of the notification

getEvent()

Get the event of the notification

bool
isRead()

Finds if the notification has been read by the user

void
markAsRead()

Mark the notification as read by the user

push()

Make sure that the user is shown the notification immediately if they are browsing

array
getActions(bool $email = false)

Get the available actions for the notification

static void
pushEvent(string $type, mixed $data = null)

Push an event to the event adapters

static void
initializeAdapters()

Initialize the external push adapters

static string[]
getActiveStatuses()

Get the possible statuses representing an active model (visible to everyone)

getQueryBuilder()

Get a query builder for notifications

Details

at line line 86
static Notification newNotification(int $receiver, string $type, Event $event, string $timestamp = 'now', string $status = 'unread')

Enter a new notification into the database

Parameters

int $receiver The receiver's ID
string $type The type of the notification
Event $event The event of the notification
string $timestamp The timestamp of the notification
string $status The status of the notification (unread, read, deleted)

Return Value

Notification An object representing the notification that was just entered

at line line 105
static Notification[] getNotifications(int $receiver, bool $onlyUnread = false)

Show a list of notifications for a specific user

Parameters

int $receiver The ID of the recipient of the notifications
bool $onlyUnread False to show both unread & read notifications

Return Value

Notification[]

at line line 123
static int countUnreadNotifications(int $receiver)

Show the number of notifications the user hasn't read yet

Parameters

int $receiver

Return Value

int

at line line 134
Player getReceiver()

Get the receiving player of the notification

Return Value

Player

at line line 146
int getCategory()

Get the type of the notification

Do not use Notification::getType(), as it returns the name of the class (i.e. notification)

Return Value

int

at line line 155
Event getEvent()

Get the event of the notification

Return Value

Event

at line line 166
bool isRead()

Finds if the notification has been read by the user

This returns true even if the notification is deleted

Return Value

bool

at line line 175
void markAsRead()

Mark the notification as read by the user

Return Value

void

at line line 188
push()

Make sure that the user is shown the notification immediately if they are browsing

at line line 199
array getActions(bool $email = false)

Get the available actions for the notification

Parameters

bool $email Whether actions should be formatted for e-mails

Return Value

array

at line line 217
static void pushEvent(string $type, mixed $data = null)

Push an event to the event adapters

Parameters

string $type The type of the event
mixed $data The data for the event

Return Value

void

at line line 251
static void initializeAdapters()

Initialize the external push adapters

Return Value

void

at line line 272
static string[] getActiveStatuses()

Get the possible statuses representing an active model (visible to everyone)

Return Value

string[]

at line line 281
static NotificationQueryBuilder getQueryBuilder()

Get a query builder for notifications