MMCenter SMS notification service for Laravel.
Star ⭐ repo to show suport 😊
Require this package with composer:
composer require avlima/laravel-sms-mmcenter
Once the package is added, the service provider and facade will be autodiscovered.
Add the ServiceProvider to the providers array in config/app.php
:
Avlima\SmsMMCenter\Providers\SmsMMCenterServiceProvider::class,
Add the Facade to the aliases array in config/app.php
:
'SmsMMCenter': Avlima\SmsMMCenter\Facades\SmsMMCenterFacade::class,
Once done, publish the config to your config folder using:
php artisan vendor:publish --provider="Avlima\SmsMMCenter\Providers\SmsMMCenterServiceProvider"
Add the keys in .env
:
MMCENTER_USER=
MMCENTER_PASSWORD=
MMCENTER_TIMEOUT=60
MMCENTER_URL=http://www.mmcenter.com.br/mmenvio.aspx,
MMCENTER_OPERATION=ENVIO
MMCENTER_ROUTE=
Once the config file is published, open config/sms-mmcenter.php
- Basic Usage
SmsMMCenter::sendMessage("TO","MESSAGE");
Add the method routeNotificationForSmsMMCenter()
to your Notifiable model:
public function routeNotificationForSmsMMCenter() {
return $this->phone; //Name of the field to be used as mobile
}
By default, your User model uses Notifiable.
Add
use Avlima\SmsMMCenter\Notifications\SmsMMCenterChannel;
and
use Avlima\SmsMMCenter\Notifications\SmsMMCenterMessage;
to your notification.
You can create a new notification with php artisan make:notification NOTIFICATION_NAME
In the via
function inside your notification, add return [SmsMMCenterChannel::class];
and add a new function toSmsMMCenter($notifiable)
to return the message body and parameters.
Notification example:-
namespace App\Notifications;
use Avlima\SmsMMCenter\Notifications\SmsMMCenterChannel;
use Avlima\SmsMMCenter\Notifications\SmsMMCenterMessage;
use Illuminate\Notifications\Notification;
class ExampleNotification extends Notification
{
public function via($notifiable)
{
return [SmsMMCenterChannel::class];
}
public function toSmsMMCenter($notifiable)
{
return (new SmsMMCenterMessage)
->to("44999999999")
->content("Hello");
}
}
Feel free to post your issues in the issues section.
Developed by Alberto Lima
MIT