Our Application has 3 Model "Notification", "Postlike" and "Post"
In Notification Model:
public function postlike()
{
return $this->belongsTo('App\Models\PostLikes', 'postlist');
}
public function post()
{
return $this->hasMany('App\Models\PostLikes', '_id', 'c_post_id');
}
In Postlike Model:
public function postlist()
{
return $this->hasMany('App\Models\Post', '_id', 'c_post_id');
}
In Notification Repository: (Query)
public function getnotification($userId)
{
$notification = $this->makeModel()
->with('post')
->with('postlike')
->with('notification')
->orderBy('created_at' , 'desc')
->where('replied_id', $userId)
->get();
return $notification;
}
For more information we have attached following Image enter image description here