Files
2023-05-12 07:02:17 -04:00

47 lines
958 B
PHP

<?php
namespace App\Telegram;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use NotificationChannels\Telegram\TelegramMessage;
class TelegramNotification extends Notification
{
use Queueable;
protected $message;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($message)
{
$this->message = $message;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
*/
public function via($notifiable): array
{
return ['telegram'];
}
/**
* Get the Telegram message representation of the notification.
*
* @param mixed $notifiable
*/
public function toTelegram($notifiable): TelegramMessage
{
return TelegramMessage::create()
->to($notifiable->routes['telegram_chat_id'])
->content($this->message);
}
}