PHP code example of enio1910 / laravel-smsapi-notification-channel

1. Go to this page and download the library: Download enio1910/laravel-smsapi-notification-channel 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/ */

    

enio1910 / laravel-smsapi-notification-channel example snippets


'providers' => [
    NotificationChannels\SmsApi\SmsApiServiceProvider::class,
],

return [
    'service' => env('SMSAPI_SERVICE', 'pl'),
    'uri' => env('SMSAPI_URI'),
    'token' => env('SMSAPI_TOKEN'),
    'from' => env('SMSAPI_FROM'),
    'timeout' => (int) env('SMSAPI_TIMEOUT', 10),
];

use Illuminate\Notifications\Notification;
use NotificationChannels\SmsApi\SmsApiChannel;
use NotificationChannels\SmsApi\SmsApiMessage;

class InvoicePaid extends Notification
{
    public function via(object $notifiable): array
    {
        return [SmsApiChannel::class];
    }

    public function toSmsApi(object $notifiable): SmsApiMessage
    {
        return SmsApiMessage::create('Faktura została opłacona.');
    }
}

$user->notify(new InvoicePaid());

\Illuminate\Support\Facades\Notification::route(SmsApiChannel::class, '+48123123123')
    ->notify(new InvoicePaid());

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

class User extends Authenticatable
{
    use Notifiable;
}

use Illuminate\Notifications\Notification;

public function routeNotificationForSmsApi(?Notification $notification = null): string
{
    return $this->phone;
}

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

class User extends Authenticatable
{
    use Notifiable;

    public function routeNotificationForSmsApi(?Notification $notification = null): string
    {
        return $this->phone;
    }
}

return SmsApiMessage::create('Faktura została opłacona.')
    ->to('+48123123123')
    ->from('MyBrand');

return SmsApiMessage::create('Faktura została opłacona.')
    ->toMany([
        '+48123123123',
        '+48999111222',
    ])
    ->from('MyBrand');

use Illuminate\Notifications\Notification;

public function routeNotificationForSmsApi(?Notification $notification = null): array
{
    return [
        '+48123123123',
        '+48999111222',
    ];
}

use Illuminate\Notifications\Notification;
use NotificationChannels\SmsApi\SmsApiChannel;
use NotificationChannels\SmsApi\SmsApiMessage;

class InvoiceWithAttachment extends Notification
{
    public function via(object $notifiable): array
    {
        return [SmsApiChannel::class];
    }

    public function toSmsApi(object $notifiable): SmsApiMessage
    {
        return SmsApiMessage::create()
            ->mms('Invoice 2026/04', '<smil><body><par><text src="invoice.txt"/></par></body></smil>')
            ->set('files[invoice.txt]', base64_encode('Invoice content'));
    }
}

return SmsApiMessage::create()
    ->to('+48123123123')
    ->mms('Invoice 2026/04', '<smil><body><par><text src="invoice.txt"/></par></body></smil>')
    ->set('files[invoice.txt]', base64_encode('Invoice content'));
bash
php artisan vendor:publish --tag=smsapi-config