Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 十月CMS插件中的电报通知_Laravel_Notifications_Telegram_Octobercms - Fatal编程技术网

Laravel 十月CMS插件中的电报通知

Laravel 十月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

我想在17:00使用laravel的电报通知频道向特定用户发送电报信息,但我似乎无法启动。我目前使用cmd命令进行测试,但不断出现错误,不知道该怎么办

以下是我的命令和通知文件:

SendNotification.php

<?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实例,它是开箱即用的


您应该同时签出和文档。

您可能想签出这篇文章