取消通知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). 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. 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. So how would I cancel it in the via? Is it possible?

所以,假设我想在Via中设置我的通知检查逻辑(如果是这样,应该基于此发送 在用户的变量上)。 我注意到,如果我这样做在via: p>

 返回$ notifiable-> comment_email?  ['mail']:false;  
  code>  pre> 
 
 

如果用户的comment_email为true,它将成功发送。 但是,如果它是假的,那么我希望一起取消通知,我假设返回False会做 - 它不会,只是抛出一个错误。 那么如何在通道中取消它呢? 有可能吗? p> div>

instead return false you must return an empty array:

return $notifiable->comment_email ? ['mail'] : [];