【发布时间】:2018-01-19 12:23:01
【问题描述】:
我们的应用程序有 3 个模型“Notification”、“Postlike”和“Post”
在通知模型中:
public function postlike()
{
return $this->belongsTo('App\Models\PostLikes', 'postlist');
}
public function post()
{
return $this->hasMany('App\Models\PostLikes', '_id', 'c_post_id');
}
在 Postlike 模型中:
public function postlist()
{
return $this->hasMany('App\Models\Post', '_id', 'c_post_id');
}
在通知存储库中:(查询)
public function getnotification($userId)
{
$notification = $this->makeModel()
->with('post')
->with('postlike')
->with('notification')
->orderBy('created_at' , 'desc')
->where('replied_id', $userId)
->get();
return $notification;
}
欲了解更多信息,我们附上了以下图片 enter image description here
【问题讨论】: