PHP code example of grafstorm / laravel-46elks-notification-channel

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

    

grafstorm / laravel-46elks-notification-channel example snippets


return [
    'user' => env('FORTY_SIX_ELKS_USER'),
    'pass' => env('FORTY_SIX_ELKS_PASS'),
    'from' => env('FORTY_SIX_ELKS_FROM', '46ELKS'),
    'base_url' => env('FORTY_SIX_ELKS_BASE_URL', 'https://api.46elks.com/a1/')
];

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

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return string[]
     */
    public function toFortySixElks($notifiable): SmsMessage
    {
        // Return a SmsMessage. Needs to and message.
        // To needs to be formatted as a [E.164](https://en.wikipedia.org/wiki/E.164) phonenumber. (Eg. +4612345678)
        return (new SmsMessage())
                ->from('developer')
                ->to($notifiable->mobile)
                ->line('Hello World')
                ->line('')
                ->line('Bye world.');
    }

use Grafstorm\FortySixElksChannel\SmsMessage;
use Grafstorm\FortySixElksChannel\Facades\FortySixElks;

$message = (new SmsMessage())
                ->to('+461')
                ->line('Hello World');
                
$sms = FortySixElks::create($message)->send();

// Use dryRun() to test sending the message.
$sms = FortySixElks::create($message)->dryRun()->send();
bash
php artisan vendor:publish --provider="Grafstorm\FortySixElksChannel\FortySixElksChannelServiceProvider" --tag="46elks-notification-channel-config"