Quick setup: User
hasAndBelongsToMany Course
courses_users
__________________________
id | user_id | course_id |
1 | 1 | 1 |
2 | 1 | 3 |
3 | 2 | 5 |
I need to load all the Courses
for the User
with users.id = 1
I tried this:
$this->User->id = $this->Auth->user('id');
$courses = $this->User->Courses->find('all');
But the code above retrieves all the courses instead of the associated to the user's ones