abstract class Notification extends Notification implements ShouldQueue (View source)

Base class for a Waterhole notification.

Waterhole builds on top of the Laravel Notifications system to make implementing notifications even easier. Waterhole takes care of all the boilerplate: managing user preferences, generating HTML emails, handling secure unsubscribe links, and rendering notifications.

To define a new Waterhole Notification type, extend this class and implement the methods to describe your notification content.

Traits

Queueable

Methods

bool
shouldSend($notifiable)

Determine whether the notification should be sent to this user.

array
via($notifiable)

Get the notification's delivery channels.

array
toArray()

Get the array representation of the notification.

Mailable|null
toMail($notifiable)

Get the mail representation of the notification.

Model|null
content()

The model associated with the individual notification instance.

User|null
sender()

The user whose action caused the notification to be sent.

string|null
icon()

The name of an icon to represent the notification.

HtmlString
title()

The title of the notification.

HtmlString
excerpt()

An excerpt from the notification content.

string|null
url()

The URL that the user should be taken to when they click the notification.

string|null
button()

The button text to be displayed on the action button in the notification email.

Model|null
group()

A common model to group multiple notifications together.

string|null
groupedUrl()

The URL that the user should be taken to when they click a grouped notification.

string|null
reason()

The reason that the user is receiving the notification.

string|null
unsubscribeText()

The label of the unsubscribe link for this notification type.

string
unsubscribeUrl($notifiable)

The URL to unsubscribe the user from this notification type.

void
unsubscribe(User $user)

Unsubscribe the user from this notification type.

static string|null
description()

A description of this notification type in the user preferences.

static void
load(Collection $notifications)

Load additional relationships onto the notifications models before displaying the notification list.

Details

bool shouldSend($notifiable)

Determine whether the notification should be sent to this user.

Parameters

$notifiable

Return Value

bool

array via($notifiable)

Get the notification's delivery channels.

For Waterhole notifications, each user is able to set a preference for which channels they would like to receive their notifications on.

Parameters

$notifiable

Return Value

array

array toArray()

Get the array representation of the notification.

Return Value

array

Mailable|null toMail($notifiable)

Get the mail representation of the notification.

Parameters

$notifiable

Return Value

Mailable|null

Model|null content()

The model associated with the individual notification instance.

This must be the same as your notification's constructor argument. It will be used to reconstruct the notification instance after the notification is read from the database.

Return Value

Model|null

User|null sender()

The user whose action caused the notification to be sent.

If present, the user's avatar will be displayed alongside the notification. In the case of a notification for a new comment, it is the author of the comment.

Return Value

User|null

string|null icon()

The name of an icon to represent the notification.

Return Value

string|null

abstract HtmlString title()

The title of the notification.

This can be a plain string or an HtmlString if you want to wrap certain words in <strong>, for example. Just be sure to escape user- generated content if returning an HtmlString.

Return Value

HtmlString

HtmlString excerpt()

An excerpt from the notification content.

Return Value

HtmlString

string|null url()

The URL that the user should be taken to when they click the notification.

Return Value

string|null

string|null button()

The button text to be displayed on the action button in the notification email.

Return Value

string|null

Model|null group()

A common model to group multiple notifications together.

For example, for a notification about a new comment, this could be the post of the comment, causing notifications for multiple new comments on the same post to be grouped together on the user's notification list.

Return Value

Model|null

string|null groupedUrl()

The URL that the user should be taken to when they click a grouped notification.

Return Value

string|null

string|null reason()

The reason that the user is receiving the notification.

Return Value

string|null

string|null unsubscribeText()

The label of the unsubscribe link for this notification type.

Return Value

string|null

string unsubscribeUrl($notifiable)

The URL to unsubscribe the user from this notification type.

Parameters

$notifiable

Return Value

string

void unsubscribe(User $user)

Unsubscribe the user from this notification type.

Parameters

User $user

Return Value

void

static string|null description()

A description of this notification type in the user preferences.

Return Value

string|null

static void load(Collection $notifications)

Load additional relationships onto the notifications models before displaying the notification list.

Parameters

Collection $notifications

Return Value

void