vendredi 9 décembre 2016

Laravel hasManyThrough() with > 1 intermediate model/table

I have a content hierarchy with four levels: a Course has Topics which have Lessons which have Questions.

I know I can use hasManyThrough to let me do $course->lessons, like this:

public function lessons() { return $this->hasManyThrough('App\Lesson', 'App\Topic'); }

It would be handy to also be able to do $course->questions

(and fantastic if that can all be done in a single query)

Is this possible?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire