[英]Canceling Notifications Laravel 5.3 (Via)
So, let's say that I want to have my Notification Check logic within Via (as in, should this be sent based on a variable on the User). 因此,假设我想在Via内放入“通知检查”逻辑(例如,应基于User上的变量发送)。 I notice that, if I do it this way in via:
我注意到,如果我通过以下方式这样做:
return $notifiable->comment_email ? ['mail'] : false;
it will successfully send if comment_email is true on the User. 如果comment_email在用户上为true,它将成功发送。 However, if it is false, then I want the notification to be cancelled all together, which I assumed returning False would do - it does not, just throws an error.
但是,如果它为false,那么我希望将通知全部取消,我以为返回False就可以了-不会,只是抛出一个错误。 So how would I cancel it in the via?
那么如何在通孔中取消呢? Is it possible?
可能吗?
而是返回false,您必须返回一个空数组:
return $notifiable->comment_email ? ['mail'] : [];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.