- Firstly, create a slack channel with the (composer requires laravel/slack-notification-channel ) command.
- Create a notification in the laravel project with the command (php artisan make: notification SlackNotification).
- Create toSlack method in the SlackNotification.
- Add routeNotificationForSlack in the user model to call toSlack method.
- Call SlackNotification from where you want to send a message.
data = $data;
public function via($notifiable)
public function toSlack($notifiable)
Log::info('in SlackMessage noti');
return (new SlackMessage)
->content(Test slack notification');
public function routeNotificationForSlack($notification)