Here my code :
$classroom_ids = $user->classrooms->pluck('id');
$classrooms = Classroom::with('students')
->whereIn('id', $classroom_ids)
->get();
I try to get all cumulated students on twos classrooms records.
I tried to use ->pluck('students') without success.
Here the classrooms datas :
0 => [
'id' : 1,
'students': Array of students
],
1 => [
'id' : 2,
'students': Array of students
],
How to get all students in one array ? Thanks
Student::whereIn('class_id', $user->classroom->pluck('id'))->get()