I have 3 models: User, Program, UserProgram. UserProgram is an actual model of its own.
Here are how the models look in the database:
- users
- id
- programs
- id
- user_programs
- user_id
- program_id
I would like to have in my Program model:
function users() { return $this->hasManyThrough('App\User','App\UserProgram'); }
But this does not work. How can I make this relationship work?