PHP code example of hachetaustralia / smsbroadcast

1. Go to this page and download the library: Download hachetaustralia/smsbroadcast 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/ */

    

hachetaustralia / smsbroadcast example snippets


// config/services.php
...
'smsbroadcast' => [
    'username' => env('SMSBROADCAST_USERNAME'),
    'password' => env('SMSBROADCAST_PASSWORD'),
    'from' => env('SMSBROADCAST_FROM'),
    'sandbox' => env('SMSBROADCAST_SANDBOX'),
],
...

// .env
...
SMSBROADCAST_USERNAME=
SMSBROADCAST_PASSWORD=
SMSBROADCAST_FROM=
SMSBROADCAST_SANDBOX=false
],
...

namespace App\Listeners;

use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use NotificationChannels\SMSBroadcast\Events\MessageWasSent;

class SentMessageHandler
{
    /**
     * Handle the event.
     *
     * @param  MessageWasSent  $event
     * @return void
     */
    public function handle(MessageWasSent $event)
    {
        $response = $event->response;
        $message = $event->message;
    }
}
 php
namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;

    public function routeNotificationForSmsBroadcast()
    {
        return $this->mobile;
    }
}
 php
namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;

    public function routeNotificationForSmsBroadcast()
    {
        return [ $this->mobile_primary, $this->mobile_secondary ];
    }
}
 php
// config/services.php
...
'smsbroadcast' => [
    'logging_channel' => env('SMSBROADCAST_LOGGING_CHANNEL'),
]
...
 php
// .env
...
SMSBROADCAST_LOGGING_CHANNEL=
...
 php
use NotificationChannels\SMSBroadcast\SMSBroadcastChannel;
use NotificationChannels\SMSBroadcast\SMSBroadcastMessage;
use Illuminate\Notifications\Notification;

class VpsServerOrdered extends Notification
{
    public function via($notifiable)
    {
        return [SMSBroadcastChannel::class];
    }

    public function toSMSBroadcast($notifiable)
    {
        return (new SMSBroadcastMessage("Your {$notifiable->service} was ordered!"));
    }
}
 php
return (new SMSBroadcastMessage("Your {$notifiable->service} was ordered!"))->setRecipients($recipients);
 php
return (new SMSBroadcastMessage("Your {$notifiable->service} was ordered!"))->setReference($id);
 php
return (new SMSBroadcastMessage("Your {$notifiable->service} was ordered!"))->setMaxSplit(2);
 php
return (new SMSBroadcastMessage("Your {$notifiable->service} is ready to go!"))->setDelay(10);
 php
return (new SMSBroadcastMessage("Your {$notifiable->service} is ready to go!"))->setPrivateReference(12345);
 php
return (new SMSBroadcastMessage("Your {$notifiable->service} is ready to go!"))->setNoFrom();