how to current use data from one with to another with ? i want to display model raport from base on model siswa

Viewed 12

how to current use data from one with to another with ? i want to display model raport from base on model siswa

public function getRekapPengetahuanSiswa($id_kelas, $id_relasi_pelajaran){

    $siswa = Relasi_kelas_siswa::where('id_kelas', $id_kelas)
    ->with('siswa.id_user')
    ->with(['siswa.relasi_kelas' => function ($querys) use ($id_relasi_pelajaran) {

        $id_siswa = $querys->get();

        $querys->with(['kelas.relasi_pelajaran' => function ($query) use ($id_relasi_pelajaran, $id_siswa) {

            $query->where('id', $id_relasi_pelajaran);

            $query->with(['topik' => function ($query2) use ($id_siswa) {
                $query2->with(['tugas' => function ($query3) use ($id_siswa) {
                    $query3->whereIn('id_sub_penilaian', Sub_penilaian::where('type', 'pengetahuan')->get('id'));

                    $query3->with(['raport' => function ($query4) use ($id_siswa) {
                        $query4->where('id_siswa', $id_siswa->last()->id);
                    }]);
                }]);

                $query2->with(['kuis' => function ($query5) {
                    $query5->whereIn('id_sub_penilaian', Sub_penilaian::where('type', 'pengetahuan')->get('id'));

                    $query5->with(['raport' => function ($query6) {
                        $query6->where('id_siswa', 1);
                    }]);
                }]);
            }]);
        }]);
    }])->get();

    return response()->json($siswa); 
}
0 Answers
Related