ivanamat / cakephp3-aclmanager

CakePHP 3.x - Acl Manager
MIT License
27 stars 27 forks source link

unable to fetch all acos for a particular aros #17

Closed dominiccliff closed 7 years ago

dominiccliff commented 7 years ago

@ivanamat I'm able to fetch the list of all acos. But I'm not able to fetch only those acos for a particular aros.

This is the code that I tried.

$acos = $this->Acl->Aco->find('all', array('order' => 'Acos.lft ASC', 'recursive' => -1))
               ->contain(['Aros' => function ($q) {
                            return $q->where(['id' => 1]);
                            //return $q->where(['Aros.id' => 1]); //this also didnt work
                        } ])->toArray(); 

is it possible to achieve the result?

Thanks for the plugin!

ivanamat commented 7 years ago

First of all, I apologize for taking so long to respond, I have changed my address, my internet service provider has left me without services for almost three months and then the laptop has touched me to take it to repair.

Have you found the solution yet?

I check the code that you sent me and I will respond soon.

ivanamat commented 7 years ago

Hi @dominiccliff,

Try this:

$cos = $this->Acl->Aco 
    ->find('all')  
    ->matching('Aros', function(\Cake\ORM\Query $q) {  
        return $q->where(['Aros.id' => 3]);  
})->toArray(); 

If I understood you correctly. This works for me.

Regards!