Laravel 十月CMS插件中的电报通知
我想在17:00使用laravel的电报通知频道向特定用户发送电报信息,但我似乎无法启动。我目前使用cmd命令进行测试,但不断出现错误,不知道该怎么办 以下是我的命令和通知文件: SendNotification.phpLaravel 十月CMS插件中的电报通知,laravel,notifications,telegram,octobercms,Laravel,Notifications,Telegram,Octobercms,我想在17:00使用laravel的电报通知频道向特定用户发送电报信息,但我似乎无法启动。我目前使用cmd命令进行测试,但不断出现错误,不知道该怎么办 以下是我的命令和通知文件: SendNotification.php <?php namespace Rogier\Lab\Console; use Illuminate\Console\Command; use Rogier\Lab\Notifications\DailyTelegram; class SendNotifica
<?php
namespace Rogier\Lab\Console;
use Illuminate\Console\Command;
use Rogier\Lab\Notifications\DailyTelegram;
class SendNotifications extends Command
{
protected $name = 'lab:notifications:send';
protected $description = 'Send notifications';
protected $userid = 919871501;
/**
* Execute the console command.
* @return void
*/
public function handle()
{
$this->output->writeln('Sending notifications');
$notification = new DailyTelegram($this->userid);
$notification->via()->toTelegram();
$this->output->writeln('Done');
}
}
和DailyTelegram.php
<?php
namespace Rogier\Lab\Notifications;
use NotificationChannels\Telegram\TelegramChannel;
use NotificationChannels\Telegram\TelegramMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Notifiable;
class DailyTelegram extends Notification
{
protected $userid = 919871501;
public function via()
{
return [TelegramChannel::class];
}
public function toTelegram()
{
return TelegramMessage::create()
// Optional recipient user id.
->to($this->userid)
// Markdown supported.
->content("Hello there!\nYour invoice has been *PAID*");
}
}
我目前在数组上得到了对成员函数TotelGram的错误调用,但我觉得我尝试了所有方法,也许我做得完全错误。有人知道我该怎么做吗
提前谢谢是的,你做错了。应呈报人有通知方法,你应该使用它:
$user->notify(new DailyTelegram);
在这个例子中,$user是App\user实例,它是开箱即用的
您应该同时签出和文档。您可能想签出这篇文章