public function recordstudentEachSectionEachTest($studentId, $newExaminationId) { /* $teachingSections = TeachingSection::where('sections_id', '=', $sectionId)->get(); $studentsIdsIncludingTeachers = DB::table('teaching_sections')->where('sections_id', '=', $sectionId)->lists('users_id'); $students = DB::table('users')->where('role', '=', '1')->whereIn('id', $studentsIdsIncludingTeachers)->get(); $studentsIds = DB::table('users')->where('role', '=', '1')->whereIn('id', $studentsIdsIncludingTeachers)->lists('id');*/ // dd($students); // dd($sectionId); // dd($newExaminationId); //generating a transcript table for each student in this examination. $newTranscript = new Transcript(); $newTranscript->examinations_id = $newExaminationId; $newTranscript->users_id = $studentId; $newTranscript->save(); $student = User::findOrFail($studentId); $teachingSection = TeachingSection::getTeachingsectionByStudent($student); $section = Section::findOrFail($teachingSection->sections_id); $school = School::findOrFail($section->schools_id); $studentArray = array(); $studentArray['name'] = $student->name; $studentArray['realname'] = $student->realname; $studentArray['sectionGrade'] = $section->grade; $studentArray['sectionOrder'] = $section->order; $studentArray['schoolName'] = $school->name; // $students = DB::table('users')->where('role', '=', '1')->whereIn('id', $studentsIds)->paginate(10); // $wholeSectionTranscripts = DB::table('transcripts')->where('examinations_id', '=', $newExaminationId)->whereIn('users_id', $studentsIds)->paginate(10); /* if (Session::has('backUrl')) { Session::keep('backUrl'); }*/ return view('scores.logStudentsTestResult', compact('newTranscript', 'studentArray')); }