dsfbnhc4373
2017-04-24 02:50
浏览 110
已采纳

取消通知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?

图片转代码服务由CSDN问答提供 功能建议

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

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

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

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongwei2882 2017-05-02 23:58
    已采纳

    instead return false you must return an empty array:

    return $notifiable->comment_email ? ['mail'] : []; 
    
    点赞 打赏 评论

相关推荐 更多相似问题