issue with query building - Property [..] does not exist on this collection instance.
Hi all,
I am trying to build an app forv university students.
My idea is to retrieve data from the database, where for each student should be displayed courses depending on which semester the student is. In other words if student A is in second semester and let's say the course Databases is being held only in second semester, for student A I should have on the page only Databases as eligible course.
I have the following relationships.
User:
public function student(){
return $this->hasOne(AdditionalInfoStudents::class,'user_id');
}
Semester:
public function student(){
return $this->hasMany(AdditionalInfoStudent::class,'semester_id');
}
public function course(){
return $this->hasMany(Course::class,'semester_id');
}
Course:
public function semester(){
return $this->belongsToMany(Semester::class);
}
AdditionalInfoStudents:
public function user(){
return $this->belongsTo(User::class);
}
public function semester(){
return $this->belongsToMany(Semester::class);
}
I wanna retrieve only the courses in semester N for a student who is in the same semester N. When trying the following I get: Property [semester_id] does not exist on this collection instance.
Can someone help me with this query?
Thanks in advance :)
Please or to participate in this conversation.