Laravel通知保存到不同的模式
我将如何强制将不同的通知保存在不同的模式中。
例如,我有两个通知表client.botifications
和business.notifications
在我的数据库中。 我希望将所有通知保存到业务架构中,但一个通知除外,我希望将其保存到客户端架构中。
这一点可能吗?
How would I force different notifications to be saved in different schemas.
For example, I have two notification tables client.botifications
and business.notifications
in my DB.
I want all notifications to be saved to the Business schema with the exception of one notification, which I would like to be saved to the Client Schema.
Is this at all possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
必须进行一些推定,我假设您是默认数据库连接,在这种情况下,
client
连接以支持您的辅助方案。如果这是相应地互换的相反方式。而且您通知是用户。如果您仔细阅读通知逻辑,则在某个时候,它将调用
$ noctififififiable- noctifications() - > creation();
这是在通知类中的,它获取notification( )
关系方法,来自这个特质。为了避免所有用户操作,可以保存在错误的连接上,当您调用Notify时,我只会更改连接,何时应将其保存在客户端连接上。Some presumptions must be made, i assume you a default database connection and in this case a
client
connection to support your secondary scheme. If it is the other way around interchange them accordingly. And you notifiable is a user.If you read through the notification logic, at some point it calls
$notifiable->notifications()->create();
This is on the notifiable class, which gets itnotification()
relationship method, from this trait. To avoid all the users operation, being saved on the wrong connection, i would just change the connection when you call the notify, when it should be saved on the client connection.