PHP code example of yna / laravel-port-to-sms

1. Go to this page and download the library: Download yna/laravel-port-to-sms 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/ */

    

yna / laravel-port-to-sms example snippets


// config/app.php
'providers' => [
    ...
    Yna\PortToSms\PortToSmsServiceProvider::class,
],

// config/services.php
...
'port2sms' => [
    'account' => env('PORT2SMS_ACCOUNT'),
    'user' => env('PORT2SMS_USER'),
    'password' => env('PORT2SMS_PASSWORD'),
    'sender' => env('PORT2SMS_SENDER')
],
...

use Illuminate\Notifications\Notification;
use Yna\PortToSms\PortToSmsMessage;
use Yna\PortToSms\PortToSmsChannel;

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

    public function toPortToSms($notifiable)
    {
        return PortToSmsMessage::create("Task #{$notifiable->id} is complete!");
    }
}

public function routeNotificationForPort2sms()
{
    return $this->phone;
}