<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
craftsys / msg91-laravel-notification-channel example snippets
// along with other services
'msg91' => [
'key' => env("MSG91_KEY")
]
namespace App\Notifications;
use Illuminate\Notifications\Notification;
use Craftsys\Notifications\Messages\Msg91SMS
class OrderPicked extends Notification
{
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
// add "msg91" channel to the channels array
return ['msg91'];
}
/**
* Get the Msg91 / SMS representation of the notification.
*
* @param mixed $notifiable
* @return \Craftsys\Notifications\Messages\Msg91SMS
*/
public function toMsg91($notifiable)
{
return (new Msg91SMS)
->flow('your_flow_id_here')
// you can also set variable's values for your flow template
// assuming you have ##order_id## variable in the flow
->variable('order_id', $notifiable->latestOrder->id);
}
}
// your Notification
public function toMsg91($notifiable)
{
return (new \Craftsys\Notifications\Messages\Msg91SMS)
->flow("your_flow_id");
}
// with variables
public function toMsg91($notifiable)
{
return (new \Craftsys\Notifications\Messages\Msg91SMS)
->flow("your_flow_id")
->variable('name', $notifiable->name)
->variable('status', "Overdue");
}
// your Notification
public function toMsg91($notifiable)
{
return (new \Craftsys\Notifications\Messages\Msg91OTP)
->from('12123');
// ->otp(12123) // set a custom otp
// ->resend() // if this is a resend otp notification
}
class User {
use Notifiable;
/**
* Route notifications for the Msg91 channel.
*
* @param \Illuminate\Notifications\Notification $notification
* @return string
*/
public function routeNotificationForMsg91 ($notification) {
return $this->phone;
}
}
public function toMsg91($notifiable)
{
return (new \Craftsys\Notifications\Messages\Msg91SMS)
->to(91992123123) // you can also pass an array for bulk notifications
->flow('your_flow_id');
}
public function toMsg91($notifiable)
{
return (new \Craftsys\Notifications\Messages\Msg91OTP)
->digits(6) // set the digits in otp message
->expiresInMinutes(1) // change the expiry time
->from("SNCBD"); // set a custom sender id
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.