【发布时间】:2015-11-05 08:21:39
【问题描述】:
我目前正在开发一个通知系统。我目前遇到的问题是所有通知都是非个人的。
我想要的是将通知保存到具有正确个性化语言的数据库中,例如,我目前有一个这样的通知,
Joe Bloggs 将 Billy Joel 添加为项目经理。
我想要的是将通知发送给不是比利乔尔的每个人,但对于比利乔尔,我希望发送以下内容
Joe Bloggs 已将您添加为项目经理
目前我将这样的通知保存在数据透视表的同步上,以供项目经理使用,
$notification = new Notification;
$notification->withURI($organisation->slug);
$notification->withIsNotification(1);
$notification->regarding($organisation);
$notification->user_id = ResourceServer::getOwnerId();
$notification->withType('updated');
//die(print_r($changes));
foreach($changes['attached'] as $k => $v) {
//Loop through each new attachment to the pivot
//look for who the attachement is from the user table and then
//add the final notification details and fire the deliver method
$addedUser = User::find($v);
$addedUserName = $addedUser->first_name . " " . $addedUser->last_name;
$notification->withBody($notifcationSenderName . " added " . $addedUserName . " to the organisation " . $organisation->name);
$notification->deliver($notifyUsers);
}
我想知道,当我通过它的模型从我的数据库中查询用户时,如果不需要个人通知并且如果然后它会返回“你”。突变器是否可以实现这一点?如果可以,如何实现?
【问题讨论】: