Laravel 5 hasManyThrough

后端 未结 2 837
礼貌的吻别
礼貌的吻别 2021-02-06 02:31

I have 3 tables: company <-> users <-> invoice.

A company hasMany users.

A user belongsTo

2条回答
  •  一整个雨季
    2021-02-06 02:58

    You can also do this in the Course class, so when you use ->with('chapters'), it automatically loads the videos too:

    public function chapters()
    {
        return $this->hasMany('Moubarmij\Models\Chapter')->with('videos');
    }
    

提交回复
热议问题