All you need to do is create two different pivot tables. One for Tests and one for Modules. So your Courses model contains a relationship of "belongsToMany('App\Test')" as well as "belongsToMany('App\Modules')" for tests() and modules() respectively. Your two pivot tables would be named course_test and course_module and contain the correct columns.
At anytime you can query a courses Tests or Modules by first getting a course (for ex $course = App\Course:first()), then you can get tests by $course->tests and modules by $course->modules if you've set the relationship up correctly.
Let me know if you need more specific code or you get the general idea of what I'm saying.
There's also no need to create Eloquent models for pivot tables. If you set up the relationships correctly Eloquent is smart enough to go and find that pivot table, it does use a naming convention that you have to use to make it work out of the box. You can specify the pivot columns though... @JeffreyWay has a great video on this: https://laracasts.com/series/laravel-5-fundamentals/episodes/21
Sign in to participate in this thread!
We'd like to thank these amazing companies for supporting us