Level 1
I solved it myself.
The query will be:
return $this->hasManyThrough('Topic', 'Class', 'id', 'id', 'class_id', 'topic_id')
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have three models : topic, class and enrollment
Topic :
class :
enrollment :
I want to query enrollment model, to get the details of topic associated with each class. I am using hasManyThrough relation like following:
return $this->hasManyThrough('Topic', 'Class', 'topic_id', 'id', 'class_id', 'id');
but its not working. Please help. Thanks
I solved it myself.
The query will be:
return $this->hasManyThrough('Topic', 'Class', 'id', 'id', 'class_id', 'topic_id')
Please or to participate in this conversation.