PHP code example of dmiseev / laravel-telegram-notification
1. Go to this page and download the library: Download dmiseev/laravel-telegram-notification 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/ */
dmiseev / laravel-telegram-notification example snippets
php
use Dmiseev\TelegramNotification\TelegramChannel;
use Dmiseev\TelegramNotification\TelegramMessage;
use Illuminate\Notifications\Notification;
class WithdrawCreate extends Notification
{
/**
* @var Withdraw
*/
private $withdraw;
/**
* @var User
*/
private $user;
/**
* @param Withdraw $withdraw
*/
public function __construct(Withdraw $withdraw, User $user)
{
$this->withdraw = $withdraw;
$this->user = $user;
}
public function via($notifiable)
{
return [TelegramChannel::class];
}
public function toTelegram($notifiable)
{
return TelegramMessage::create()
->to($this->user->telegram_user_id)
->content("*HI!* \n One of your withdraws has been created!")
->button('View Withdraw', url('/withdraws/' . $this->withdraw->id));
}
}
php
...
/**
* @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.