【问题标题】:Prevent a Laravel notification to be sent阻止发送 Laravel 通知
【发布时间】:2020-03-19 15:25:41
【问题描述】:

我正在开发一个功能来发送“级联”或notifications 链,它们之间有不同的通道延迟。例如:

电子邮件 ->(30 分钟后)-> 推送 ->(30 分钟后)-> 短信

该流程运行良好,现在是用户完成某事或执行我希望链停止的操作。所以我停止或阻止发送通知。这是我尝试过的,但stop them 似乎没有。

我试过了:

public function via($notifiable)
{
    if (whatever condition to stop) {
        return null; // also tried with return []
    }

    return ['mail'];
}

还有

public function __construct(array $data = [])
{
    if (whatever condition to stop) {
        exit; // are you desperate, bruh?
    }
}

有什么我没有看到的超级明显的东西吗?可能与我们的自定义调度程序有关。 您知道我可以在哪里中断应用程序以阻止发送通知吗?

【问题讨论】:

    标签: php laravel notifications


    【解决方案1】:

    其实这样就够了:

    public function via($notifiable)
    {
        if (whatever condition to stop) {
            return [];
        }
    
        return ['mail'];
    }
    

    问题是别的,Docker 向我展示了文件的缓存版本,所以它们总是返回 return ['mail'];

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-02-17
      • 1970-01-01
      • 2019-11-11
      • 1970-01-01
      • 1970-01-01
      • 2017-08-25
      • 2020-01-28
      相关资源
      最近更新 更多