File: /var/www/wsklad/app/Notifications/TelegramMessages.php
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use NotificationChannels\Telegram\TelegramMessage;
use Illuminate\Notifications\Notification;
class TelegramMessages extends Notification
{
use Queueable;
public $message;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($message)
{
$this->message = $message;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['telegram'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\TelegramMessage
*/
public function toTelegram($notifiable)
{
return TelegramMessage::create()
->to(config('services.telegram-bot-api.chat_id'))
->token(config('services.telegram-bot-api.token'))
->content($this->message);
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}