1. Go to this page and download the library: Download maxbond/telegram-custom-url 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/ */
php
use NotificationChannels\Telegram\TelegramChannel;
use NotificationChannels\Telegram\TelegramMessage;
use Illuminate\Notifications\Notification;
class InvoicePaid extends Notification
{
public function via($notifiable)
{
return [TelegramChannel::class];
}
public function toTelegram($notifiable)
{
$url = url('/invoice/' . $this->invoice->id);
return TelegramMessage::create()
->to($this->user->telegram_user_id) // Optional.
->content("*HELLO!* \n One of your invoices has been paid!") // Markdown supported.
->button('View Invoice', $url); // Inline Button
}
}
php
...
/**
* Route notifications for the Telegram channel.
*
* @return int
*/
public function routeNotificationForTelegram()
{
return $this->telegram_user_id;
}
...
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.