cakephp - Multi contains and filter -


i need make difficult request lot of contains don't understand how filter results on contains.

my tables that:

menus hasmany sousmenus

sousmenus hasmany droits

droits belongstomany roles

roles belongstomany services

i know services_id , want menus contain sousmenus contain droits contain role where:

roles linked service_id

droits linked these roles

sousmenus linked these droits

and menus linked sous_menus.

it's difficult explain.

edit: tried doesn't work:

$menus = tableregistry::get('menus'); $query = $menus->find()->contain(['sousmenus.droits.roles.services'])->matching('sousmenus.droits.roles.services', function ($q) {     return $q->where(['services.id' => 6]); }); 


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -