PHP code example of laravel-notification-channels / gammu

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

    

laravel-notification-channels / gammu example snippets


// config/app.php
'providers' => [
    ...
    NotificationChannels\Gammu\GammuServiceProvider::class,
],

...
'gammu' => [
    'method' => env('GAMMU_METHOD', 'db'),
    'sender' => env('GAMMU_SENDER', null),
],
...

// config/database.php
...
'connections' => [
    ...
    'gammu' => [
        'driver' => 'mysql',
        'host' => env('DB_GAMMU_HOST', 'localhost'),
        'port' => env('DB_GAMMU_PORT', '3306'),
        'database' => env('DB_GAMMU_DATABASE', 'forge'),
        'username' => env('DB_GAMMU_USERNAME', 'forge'),
        'password' => env('DB_GAMMU_PASSWORD', ''),
        'charset' => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => null,
    ],
    ...
],
...

namespace App\Notifications;

use NotificationChannels\Gammu\GammuChannel;
use NotificationChannels\Gammu\GammuMessage;
use Illuminate\Notifications\Notification;

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

    public function toGammu($notifiable)
    {
        return (new GammuMessage())
            ->to($phoneNumber)
            ->content($content);
    }
}

public function toGammu($notifiable)
{
    return (new GammuMessage())
        ->to($phoneNumber)
        ->sender($sender)
        ->content($content);
}

...
/**
 * Route notifications for the Gammu channel.
 *
 * @return string
 */
public function routeNotificationForGammu()
{
    return $this->phone;
}
...
 php
...
'gammu' => [
    'method' => env('GAMMU_METHOD', 'redis')
],
...