I would like to get all quizzes with the topics which have a course_id:
The Topic model has the following function:
public function quizzes()
{
return $this->hasMany('App\Quiz');
}
The Quizzes model has the following function:
public function topic()
{
return $this->belongsTo('App\Topic', 'topic_id');
}
This is the code in my controller function:
$topics = Topic::with('quizzes')->whereCourseId($course_id)->orderBy('created_at', 'asc')->get();
return dd($topics->quizzes);
I get the following Exception error:
Property [quizzes] does not exist on this collection instance.
I seem not to know whats happening?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire