首页 > 解决方案 > laravel 松弛消息未发送

问题描述

我遵循了一些关于如何通过 Laravel 发送 Slack 消息的教程。公共函数 routeNotificationForSlack($notification) 从未被调用,但我不知道为什么。

我的通知句柄看起来像这样,待办事项由以 ->get() 类结尾的雄辩查询检索: NotifyTodo :

foreach($todos as $todo) {

    $reminder = new RemindTodo($todo);

    $reminder->toSlack($reminder);
}

我的 toSlack 函数类 :RemindTodo:

public function toSlack($notifiable)
{
    $todo = $this->todo;

    return (new SlackMessage)
        ->success()
        ->content($todo['description']);
}

还有我的 :Todo: 模型,其中包含使用 Notifiable; 和 routeNotificationForSlack 方法:

public function routeNotificationForSlack($notification)
{
    dd('test');
    return env('SLACK_WEBHOOK_URL');
}

标签: laravelnotificationsslack

解决方案


如果您使用 .env,请尝试清除缓存,如下所示:

php artisan cache:clear

推荐阅读