Notification
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
Methods
Determine whether the notification should be sent to this user.
Get the notification's delivery channels.
Get the array representation of the notification.
Get the mail representation of the notification.
The model associated with the individual notification instance.
The user whose action caused the notification to be sent.
The name of an icon to represent the notification.
The title of the notification.
An excerpt from the notification content.
The URL that the user should be taken to when they click the notification.
The button text to be displayed on the action button in the notification email.
A common model to group multiple notifications together.
The URL that the user should be taken to when they click a grouped notification.
The reason that the user is receiving the notification.
The label of the unsubscribe link for this notification type.
The URL to unsubscribe the user from this notification type.
A description of this notification type in the user preferences.
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.
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.
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.
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.
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.
string|null
icon()
The name of an icon to represent the notification.
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
.
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.
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.
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.