1. Go to this page and download the library: Download emotality/panacea-laravel 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/ */
namespace App\Notifications;
use Emotality\Panacea\PanaceaMobileSms;
use Emotality\Panacea\PanaceaMobileSmsChannel;
use Illuminate\Notifications\Notification;
class ExampleNotification extends Notification
{
// Notification channels
public function via($notifiable)
{
return [PanaceaMobileSmsChannel::class];
}
// Send SMS
public function toSms($notifiable) // Can also use toPanacea($notifiable)
{
// Send SMS without "to", this value will automatically be fetched from
// the "routeNotificationForPanacea" method in your notifiable entity.
// See the "Routing SMS Notifications" section below.
return (new PanaceaMobileSms())->message("1st Line\n2nd Line\n3rd Line");
// or send SMS to a single recipient, specifying the "to" value
return (new PanaceaMobileSms())
->to($notifiable->mobile) // Assuming $user->mobile is their mobile number
->from('From Name') // Optional. Will override config's "from" value.
->message("1st Line\n2nd Line\n3rd Line");
// or send SMS to multiple recipients
return (new PanaceaMobileSms())
->toMany(['+27820000001', '+27820000002'])
->from('From Name') // Optional. Will override config's "from" value.
->message("1st Line\n2nd Line\n3rd Line");
}
}
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use Notifiable;
/**
* Route notifications for the Panacea channel.
*
* @param \Illuminate\Notifications\Notification $notification
* @return string
*/
public function routeNotificationForPanacea($notification)
{
return $this->mobile;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.