How to get related tables?

0 like 0 dislike
15 views
Have a project where in the database 3 tables, users, sites list and the table containing a list of websites tied to users. As from the model user to obtain a list of sites ?
//table: users, sites, site_user
asked by | 15 views

2 Answers

0 like 0 dislike
User::find($userId)->sites();
But in the models needs to be spelled out
answered by
0 like 0 dislike
answered by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
asked Oct 5, 2018 by kiukishenkaec
0 like 0 dislike
1 answer
24,509 questions
45,932 answers
0 comments
346 users