Laravel - Notifications - Custom Channels
Laravel ships with a handful of notification channels, but you may want to write your own drivers to deliver notifications via other channels. Laravel makes it simple. To get started, define a class that contains a send
method. The method should receive two arguments: a $notifiable
and a $notification
.
Within the send
method, you may call methods on the notification to retrieve a message object understood by your channel and then send the notification to the $notifiable
instance however you wish:
toVoice($notifiable);
// Send notification to the $notifiable instance...
}
}
Once your notification channel class has been defined, you may return the class name from the via
method of any of your notifications. In this example, the toVoice
method of your notification can return whatever object you choose to represent voice messages. For example, you might define your own VoiceMessage
class to represent these messages: