I have a Model of Users,
and a Model of Companies

each User belongs to a Company:
   public $belongsTo = 'Company';

each Company has many Users:
 public $hasMany = 'User';

A user logs in. It's an ordinary user (not an administrator).

I'm in the UsersController.php, function index, and I want to display only
other users that belong to the same company the logged in user belongs to.
How do I fetch that info?

e.g.
$this->set('users', $this->Paginator->paginate());

will display *all* users. Suitable for admin users, not for regular users.
How do I restrict the list of users to only users belonging to the same
company the user belongs to?

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to