I had 4 tables that look like this:
users
id
classrooms
id
classroom_user
classroom_id
user_id
assignments
id
classroom_id
A user is belongs to many classroom and a classroom has many assignment. How do i get all the assignment from all the classroom that i joined? My current code is look like this:
$request
->user()
->classrooms()
->with('assignments')
->paginate()
Yes, indeed, it load all the assignment from all the classroom that i joined, but the assignments is showed inside each classroom array, how do i get only array of assignment without the classroom? Thanks before.