Skip to content

emotality/panacea-laravel

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 

PanaceaMobile for Laravel

License Latest Version Total Downloads

Laravel package to send transactional SMSes via PanaceaMobile.

Requirements

  • PHP 7.2+
  • Laravel 7.0+

Installation

  1. composer require emotality/panacea-laravel
  2. php artisan vendor:publish --provider="Emotality\Panacea\PanaceaMobileServiceProvider"
  3. Add the following lines to your .env file:
PANACEA_USERNAME="<panacea_username>"
PANACEA_PASSWORD="<panacea_password_or_api_key>"
PANACEA_FROM="<from_name>" // Optional, but required for sending outside ZA

Usage

Sending an SMS to a single recipient:

\PanaceaMobile::sms('+27820000001', "1st Line\n2nd Line\n3rd Line");

Response will be a bool, true if successful, false if unsuccessful.


Sending an SMS to multiple recipients:

\PanaceaMobile::smsMany(['+27820000001', '+27820000002'], "1st Line\n2nd Line\n3rd Line");

Response will be an array where the keys are the recipients' numbers, the values will be booleans:

array:2 [▼
  "+27820000001" => true
  "+27820000002" => false
]

Sending an SMS via notification:

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 to a single recipient
        return (new PanaceaMobileSms())
            ->to($notifiable->mobile) // Assuming $user->mobile
            ->message("1st Line\n2nd Line\n3rd Line");
            
        // or send SMS to multiple recipients
        return (new PanaceaMobileSms())
            ->toMany(['+27820000001', '+27820000002'])
            ->message("1st Line\n2nd Line\n3rd Line");
    }
}

License

panacea-laravel is released under the MIT license. See LICENSE for details.