I'm creating a basic student/course script. I have 3 models I'm working with: Student, Course, StudentCourse. Below are the relationships:
Student:
- 'hasMany' Course
- 'hasMany' StudentCourse
Course:
- 'belongsTo' Student (This is the course INSTRUCTOR)
- 'hasMany' StudentCourse
- 'hasAndBelongsToMany' Student (these are the students signed up for the course)
StudentCourse:
- 'belongsTo' Student
- 'belongsTo' Course
Now, I'm running into some problems when I'm trying to get all of the students who have signed up for a course (because it's also returning the instructor for the course and messing up the array). How can I make it so that the "belongsTo" in "Course" uses an alias called "Instructor" (this way when I get data for a "Course", I have: $course['Course'](course data), $course['Instructor'](instructor's data, referenced by student_id in the courses table) and $course['Students'](students signed up for course)?
Here are the controllers/the view call: http://bin.cakephp.org/view/645421766