Skip to content

Instantly share code, notes, and snippets.

@ibayazit
Created July 27, 2022 10:03
Show Gist options
  • Save ibayazit/b94a32d226ff664f267be878c2d83f86 to your computer and use it in GitHub Desktop.
Save ibayazit/b94a32d226ff664f267be878c2d83f86 to your computer and use it in GitHub Desktop.
Laravel custom notification channel. Example sms notification
#channel -------------------
<?php
namespace App\Channels;
use Illuminate\Notifications\Notification;
class SmsChannel
{
public function send($notifiable, Notification $notification)
{
$notification->toSms($notifiable);
return true;
}
}
#appProvider -------------------
use Illuminate\Support\Facades\Notification;
use App\Channels\SmsChannel;
public function boot()
{
Notification::extend('sms', function ($app) {
return new SmsChannel();
});
}
#Notification -------------------
public function toSms($notifiable)
{
// Send sms code...
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment