This package(non-official) makes it easy to send notifications using Mitake with Laravel 5.5+ and 6.x and 7.x
Here's the latest documentation on Laravel's Notifications System:
https://laravel.com/docs/master/notifications
composer require natsumework/laravel-notification-mitake
Add your Mitake Account, Password, and Api endpoint url (optional) to your config/services.php
:
// config/services.php
...
'mitake' => [
'username' => env('MITAKE_USERNAME'), // reqired
'password' => env('MITAKE_PASSWORD'), // reqired
'url' => env('MITAKE_URL'), // optional (has default value): e.g. 'https://{三竹網域名稱}/api/mtk/SmSend
],
...
Now you can use the channel in your via() method inside the notification:
use NotificationChannels\Mitake\MitakeChannel;
use NotificationChannels\Mitake\MitakeMessage;
use Illuminate\Notifications\Notification;
class SmsNotification extends Notification
{
public function via($notifiable)
{
return [MitakeChannel::class];
}
public function toMitake($notifiable)
{
return (new MitakeMessage())
->content("Your message...");
}
}
You can also set 'dstaddr' or 'vldtime' or 'clientid' option (about the options please refer to the mitake api docs):
class SmsNotification extends Notification
{
...
public function toMitake($notifiable)
{
return (new MitakeMessage())
->content("Your message...")
->to("0900000000") // dstaddr: phone number
->vldTime("900") // Validity period: 900 second
->clientId("ce910656-7bd1-11ea-bc55-0242ac130003"); //Check duplicate sending
}
...
In order to let your Notification know which phone are you sending to, you need to set the phone number in MitakeMessage
class SmsNotification extends Notification
{
...
public function toMitake($notifiable)
{
return (new MitakeMessage())
->to("0900000000") // dstaddr: phone number
...
}
...
You can also add the routeNotificationForMitake method to your Notifiable model.
public function routeNotificationForMitake()
{
return '0900000000';
}
or you can use the on-demand-notifications
Notification::route('mitake', '0900000000')
->notify(new SmsNotification($message));
Please see CHANGELOG for more information what has changed recently.
$ composer test
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.