Laravel如何检查是否已发出通知

发布于 2025-01-31 00:28:21 字数 985 浏览 1 评论 0原文

我最初有此电子邮件通知,该通知是按需或按计划触发的。我想知道如何确定是否已派发通知(未找到错误)(Failed_jobs表中报告的错误)。

要触发的可引用类:

<?php

class SendCertificates
{
    public function __invoke()
    {
                if($this->send_certificate($certificate)){
                    //NEVER EXECUTED, since return is VOID
                    $this->mark_as_delivered($certificate);
                }else{
                    //handle not sent, check error, etc.
                }

    }

    public function send_certificate(Certificate $certificate)
    {
        //'void' method 'notify' result used
        return Notification::route('mail',[
            $certificate->participant->email=>$certificate->participant->name,
        ])->notify(new CertificateIssued($certificate))
            ;
    }

}

对于最后一个返回通知有此警告:

'void'方法'notify'使用

,如何确定通知的结果?告诉它是否是派遣的?

I initially have this email notification, which is triggered either on demand or on schedule. I want to know how to determine whether the notification has been dispatched (no errors found) or not (error reported in the failed_jobs table).

Invokable class to be triggered:

<?php

class SendCertificates
{
    public function __invoke()
    {
                if($this->send_certificate($certificate)){
                    //NEVER EXECUTED, since return is VOID
                    $this->mark_as_delivered($certificate);
                }else{
                    //handle not sent, check error, etc.
                }

    }

    public function send_certificate(Certificate $certificate)
    {
        //'void' method 'notify' result used
        return Notification::route('mail',[
            $certificate->participant->email=>$certificate->participant->name,
        ])->notify(new CertificateIssued($certificate))
            ;
    }

}

For that last return Notification there's this warning:

'void' method 'notify' result used

So how do I determine the result of the Notification? To tell whether it was dispatched or not?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文