mardi 20 septembre 2016

Laravel table relationship for getting user list

I'm working on a laravel 5 application. I have 3 tables:

table A: 'users' 

id   |    name
————————————————
1    |    Dave
2    |    Robet
3    |    Jimmy
4    |    Daniel

and Table B classroom_users

user_id | classroom_id 
1       | 5            
4       | 5            
3       | 6  
4       | 5          

I need to return all users 'name' for classroom 5

Please let me know what is the best way to do that. Trough model or Database join

Any help appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire