How to find users based on groups defined in ACL in CakePHP?
I'm using CakePHP here. Let's say I have 3 groups of user, namely:
- Super Admin
- Admin
- Customer
and this scenario has been setup using ACL.
Now, how do I return only users that belong to a particular group? e.g. Find all Customer only
I am able to do this using pure SQL statement:
SELECT *
FROM `users`
WHERE `id`
IN (
SELECT foreign_key
FROM `aros`
WHERE `parent_id` =3
)
How do I do it in CakePHP wa开发者_如何转开发y of using $this->Model->find();
?
The way is the same as in all find cases:
$users = $this->User->find('all', array('conditions'=>array('User.aro_id'=>3)));
Basically it depends from the relation, but as far I understand it's Group hasMany Users.
精彩评论