PHP code example of andreasnij / laravel-sms-notification-channel
1. Go to this page and download the library: Download andreasnij/laravel-sms-notification-channel library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
andreasnij / laravel-sms-notification-channel example snippets
class TestUser
{
use Notifiable;
public string $phone_number = '46700000000';
public function routeNotificationForSms(Notification $notification): ?string
{
return $this->phone_number;
}
}
class TestNotification extends Notification
{
public function via(mixed $notifiable): array
{
return ['sms'];
}
public function toSms(mixed $notifiable): string
{
return 'Test message';
}
}
$user = new User();
$user->notify(new TestNotification());
use AnSms\SmsTransceiverInterface;
use AnSms\Message\Message;
$smsTransceiver = app(SmsTransceiverInterface::class);
$message = Message::create('46700000000', 'Hello world!');
$smsTransceiver->sendMessage($message);