Esempio n. 1
0
 public function students($classroom_id, $student_id = null)
 {
     $classroom = Classroom::findOrFail($classroom_id);
     //->has('students', '<=', 'classrooms.attendees_limit')
     $classrooms = Classroom::select(DB::raw('CONCAT(hour , "-", code , "-" , day) as code , id'))->where('subject_subject_id', $classroom->subject_subject_id)->whereIn('classrooms.gender', [$classroom->gender, 'b'])->inCurrentSemester()->pluck('code', 'id')->toArray();
     $days = $this->days;
     foreach ($classrooms as $key => $value) {
         $day = substr($value, -1);
         $new_day = $days[$day];
         $classrooms[$key] = substr_replace($classrooms[$key], $new_day, -1);
     }
     $subjects = Subject::where('id', $classroom->subject_subject_id)->first()->name;
     $students = Student::with(['classrooms' => function ($query) use($classroom_id, $student_id) {
         return $query->where('classrooms.id', $classroom_id);
     }]);
     if (isset($student_id)) {
         $students = $students->whereHas('classrooms', function ($query) use($classroom_id, $student_id) {
             $query->where('classrooms.id', $classroom_id)->where('students.username', $student_id);
         })->get();
     } else {
         $students = $students->whereHas('classrooms', function ($query) use($classroom_id, $student_id) {
             $query->where('classrooms.id', $classroom_id);
         })->get();
     }
     // dd($classrooms);
     return view('classrooms::classrooms.students', compact('students', 'classroom', 'classrooms', 'subjects'));
 }
Esempio n. 2
0
 public function classroomsedit($student_id, $classroom_id)
 {
     $student = Student::findOrFail($student_id);
     //$subjects = Subject::with('classroom')->Student($student->id)->findOrFail($subject_id);
     $subject_id = Classroom::findOrFail($classroom_id)->subject_subject_id;
     $classrooms = Classroom::with('students')->where('subject_subject_id', $subject_id)->get();
     // dd($subject_id);
     // $classroom_id= $classrooms->id;
     return view('students::classrooms.edit', compact('classroom_id', 'student', 'classrooms', 'student_id'));
 }