PHP code example of a-mazalov / a1-notification-channel

1. Go to this page and download the library: Download a-mazalov/a1-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/ */

    

a-mazalov / a1-notification-channel example snippets


// config/a1.php

return [
    "api_key" => env('A1_API_KEY', null),
    "api_login" => env('A1_API_LOGIN', null),
    "api_scheme" => env('A1_API_SCHEME', 'http'),
    "api_endpoint" => env('A1_API_ENDPOINT', 'http://smart-sender.a1.by/api/'),
];

A1_API_KEY=
A1_API_LOGIN=
A1_API_SCHEME=http
A1_API_ENDPOINT=http://smart-sender.a1.by/api/

// bootstrap/app.php

$app->register(A1\Channel\A1ServiceProvider::class);

// Опционально регистрация фасада
$app->withFacades(true, [
    // ...
    'A1\Channel\A1Facade' => 'A1Client',
]);

// A1\Channel\A1Client;

A1Client::sendSms('375290001122', 'Текст сообщения');
bash
php artisan vendor:publish --provider="A1\Channel\A1ServiceProvider" --tag="config"
 php
namespace App\Notifications;

use A1\Channel\A1Message;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class TestNotification extends Notification
{
    use Queueable;
    
    public $message;

    public function __construct($message)
    {
        $this->message = $message;
    }

    public function via($notifiable)
    {
        return ['a1'];
    }

    // ..

    public function toA1($notifiable)
    {
        return (new A1Message)
            ->content($this->message);
    }
}
 php
// App\Models\v1\Employee
// Так же необходимо добавить трейт для уведомлений
use Notifiable;

public function routeNotificationForA1()
{
    return $this->mtel ? '375' . $this->mtel : null;
}
 php
$user->notify(new Notification())