Provides Beem notification channel for Laravel
davidpella/beem-sms-laravel is a Laravel package for provides beem notification channel for laravel.
It currently has 0 GitHub stars and 9 downloads on Packagist (latest version 0.1.0).
Install it with composer require davidpella/beem-sms-laravel.
Discover more Laravel packages by davidpella
or browse all Laravel packages to compare alternatives.
Last updated
This package makes it easy to send Beem SMS notifications with Laravel 8.x
Sending an SMS to a user becomes as simple as using:
use App\Notifications\AccountCreated;
$user->notify(new AccountCreated);
Or on-demand notifications
use App\Notifications\AccountCreated;
use Illuminate\Support\Facades\Notification;
Notification::route("beem-sms", "255762000000")->notify(new AccountCreated);
You can install the package via composer:
composer require davidpella/beem-sms-laravel
Add your Beem Account api_key, api_secret, and source_address to your .env:
BEEM_SMS_SOURCE_ADDRESS=
BEEM_SMS_API_KEY=
BEEM_SMS_SECRET_KEY=
Run to public configuration file config directory
php artisan vendor:publish --provider="DavidPella\BeemSms\BeemSmsServiceProvider"
Now you can use the channel in your via() method inside the notification:
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use DavidPella\BeemSms\Channel\BeemSmsChannel;
use Illuminate\Notifications\Notification;
use DavidPella\BeemSms\Channel\BeemSmsMessage;
class AccountCreated extends Notification
{
use Queueable;
public function via($notifiable):array
{
return [BeemSmsChannel::class]; // or ["beem-sms"]
}
public function toBeemSms($notifiable):BeemSmsMessage
{
return (new BeemSmsMessage())
->content("Your {$notifiable->name} account was created!");
}
}
In order to let your Notification know which phone are you sending to, the channel will look for the phone attribute of the Notifiable model.
If you want to override this behaviour, add the routeNotificationForBeemSms method to your Notifiable model.
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use Notifiable;
public function routeNotificationForBeemSms()
{
return $this->phone_number;
}
}
Or
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use Notifiable;
public function routeNotificationForBeemSms()
{
return "255762000000";
}
}
To use the Beem Sms Client Library you can use the facade:
use DavidPella\BeemSms\Facades\BeemSms;
BeemSms::send([
"recipient" => "255762000000",
"message" => "Using the facade to send a message.",
]);
Or request the instance from the service container
app("DavidPella\BeemSms\BeemSmsClient")
->recipient("255762000000")
->message("Send sms message using laravel service container")
->dispatch();
composer test
Please see CHANGELOG for more information on what has changed recently.