PHP code example of websms / laravel-notification

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

    

websms / laravel-notification example snippets


$ composer 

// config/app.php
'providers' => [
    ...
    Websms\LaravelNotification\WebSmsServiceProvider::class,
]

// config/services.php

...
'websms' => [
'username' => env('WEBSMS_USERNAME'),
'password' => env('WEBSMS_PASSWORD'),
'sendNumber' => env('WEBSMS_SENDNUMBER'),
],
...

// .env

WEBSMS_USERNAME=your_username
WEBSMS_PASSWORD=your_password
WEBSMS_SENDNUMBER=send_number

/**
 * Get the notification's delivery channels.
 *
 * @param  mixed  $notifiable
 * @return array
 */
public function via($notifiable)
{
    return [WebSmsChannel::class];
}

/**
 * Get the sms representation of the notification.
 *
 * @param  mixed  $notifiable
 * @return string
 */
public function toSms($notifiable)
{
    $webSmsMessage = new WebSmsMessage();
    $webSmsMessage->setFrom(env('WEBSMS_SENDNUMBER'));
    $webSmsMessage->setTo($notifiable->routeNotificationFor('sms'));
    $webSmsMessage->setMessage($this->message);

    return $webSmsMessage;
}

public function routeNotificationForSms()
{
    return $this->phone; // where `phone` is a field in your users table;
}