middleware('auth'); } function printReportCard($idno) { if (Auth::user()->accesslevel == "3" || Auth::user()->accesslevel == "2") { $user = \App\User::where('idno', $idno)->first(); $student_info = \App\StudentInfo::where('idno', $idno)->first(); $status = \App\Status::where('idno', $idno)->first(); $levels = \App\Curriculum::distinct()->where('curriculum_year', $student_info->curriculum_year)->where('program_code', $status->program_code)->orderBy('level')->get(['level', 'period']); if($status->academic_type == "College" || $status->academic_type == "TESDA"){ $school_year = \App\CtrGradeSchoolYear::where('academic_type',"College")->first(); $courses = \App\GradeCollege::where('idno',$idno)->where('school_year',$school_year->school_year)->where('period',$school_year->period)->get(); $pdf = PDF::loadView('registrar.student_record.print.print_report_card_college', compact('idno', 'student_info','school_year','status', 'user', 'levels', 'curriculum','courses')); $pdf->setPaper('letter','portrait'); } elseif($status->academic_type == "Senior High School"){ $school_year = \App\CtrGradeSchoolYear::where('academic_type', "Senior High School")->first(); $courses = \App\GradeShs::where('idno', $idno)->where('school_year', $school_year->school_year)->where('period', $school_year->period)->get(); $pdf = PDF::loadView('registrar.student_record.print.print_card_slip_shs', compact('idno', 'student_info', 'school_year', 'status', 'user', 'levels', 'curriculum', 'courses')); $pdf->setPaper('letter', 'portrait'); } elseif($status->academic_type == "Junior High School"){ $school_year = \App\CtrSchoolYear::where('academic_type', "Junior High School")->first(); $courses = \App\BedGrade::where('idno', $idno)->where('school_year', $school_year->school_year)->get(); $pdf = PDF::loadView('registrar.student_record.print.print_card_slip_jhs', compact('idno', 'student_info', 'school_year', 'status', 'user', 'levels', 'curriculum', 'courses')); $pdf->setPaper('letter', 'portrait'); } \App\Http\Controllers\Admin\Logs::log("Student Record","Print Report Card for $idno"); return $pdf->stream("report_card_" . $idno . ".pdf"); } } }