I have 3 Models.
Menus -> BelongsToMany -> Tags -> BelongsToMany -> Posts.
I am getting menu_slug as Input and I have to Paginate the Posts that are coming.
The query that I wrote is working as expected but I am not able to Paginate it according to Posts.
My query is:
$posts=$this->Menus->findByMenuSlug($slug)->contain(['Tags'=>function($query){
return $query->contain(['Posts'=>function($qry){
return $qry->select(['id','title','slug','short_description','created'])->where(['status'=>1,'is_deleted'=>2,'is_approved'=>1])->orderDesc('Posts.created');
}]);
}])->first();`
I don't have any Idea how to Implement this using Paginator. Please help.