Defining Notifications
Last updated
Last updated
Notifications are CFCs that extend .
You can create and set any custom properties you want to store on the notification.
The via
method defines what channels the Notification
will be sent by returning an array of channel names. It can return a static array or it can use the passed Notifiable
instance to dynamically determine the channels.
You may choose certain channels for a certain Notifiable
type, like only sending SMS messages to User
instances, not Team
instances.
You can also store Notifiable
-specific configuration, like allowing a User
to opt-in to certain channels like sms
, email
, or slack
.
For each channel type that the Notification
could be sent on you need to implement a matching to{ChannelType}
method.
For instance, if you are using a DatabaseProvider
, you need a toDatabase
method.
The to{ChannelType}
methods also receive the Notifiable
reference as an argument in case you need to return different data based on the specific Notifiable
instance.
Each Provider has their own requirements for their to{ChannelType}
methods. See the Provider-specific documentation for more information.
The required methods for you to implement are the method and any methods that the notification could be sent to.