Created
July 27, 2022 10:03
-
-
Save ibayazit/b94a32d226ff664f267be878c2d83f86 to your computer and use it in GitHub Desktop.
Laravel custom notification channel. Example sms notification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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