1. Go to this page and download the library: Download alimousavi/telenotify 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/ */
alimousavi / telenotify example snippets
use Alimousavi\TeleNotify\Contracts\TeleNotifiableInterface;
class User implements TeleNotifiableInterface
{
// ...
public function getTelegramChatId(): string|int|null
{
return $this->telegram_chat_id;
}
}
use Alimousavi\TeleNotify\Contracts\TeleNotifiableInterface;
use Alimousavi\TeleNotify\Traits\TeleNotifiable;
class User implements TeleNotifiableInterface
{
use TeleNotifiable;
// ...
}
use Illuminate\Notifications\Notification;
use Alimousavi\TeleNotify\Channels\TelegramChannel;
use Alimousavi\TeleNotify\Contracts\TeleNotifiable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Bus\Queueable;
class ExampleNotification extends Notification implements ShouldQueue
{
use Queueable;
public function via($notifiable)
{
return [TelegramChannel::class];
}
public function toTelegram(TeleNotifiable $notifiable)
{
return [
'text' => 'Hello, this is a test message from TeleNotify!',
];
}
}
public function toTelegram(TeleNotifiable $notifiable)
{
return [
'text' => 'Hello, this is a simple text message!',
];
}
public function toTelegram(TeleNotifiable $notifiable)
{
return [
'text' => 'Hello, this message uses *Markdown* parse mode.',
'parse_mode' => 'Markdown',
];
}
public function toTelegram(TeleNotifiable $notifiable)
{
return [
'text' => 'Hello, this message will not trigger a notification.',
'disable_notification' => true,
];
}