Hello, I’m looking for a way to get all the coworkers in a department of the currently logged in user.
Howver, the user is part of a team (foreign key: team_id, which links to the teams table) and each team is part of a department (foreign key: department_id, which links to the departments table). So far I have this script, but this only gives me the employees from the current users team:
$users = $this->Requests->Users->find('list', [
'conditions' => ['Users.team_id =' => $this->Auth->user('team_id')]
]);
I’ve done something like this before through some very ugly foreaching and I was wondering what would be the best practise of doing this. I’m hoping somebody can help me out.