コード例 #1
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     if (Auth::guest()) {
         return view('home');
     }
     $user = \Auth::user();
     $classes = [];
     $totalClasses = Classe::all()->count();
     $totalSubjects = Subject::all()->count();
     $totalStaffs = Teacher::all()->count();
     $totalStudents = Student::all()->count();
     if ($user->type != "Student") {
         $id = Teacher::where('teacherId', $user->userId)->get();
         foreach ($id as $id) {
             $id = $id->id;
         }
         $teacher = Teacher::find($id);
         //dd($teacher);
         //dd($teacher);
         foreach ($teacher->classes as $classe) {
             $classes[] = $classe;
         }
         foreach ($teacher->subjects as $subject) {
             $subjects[] = $subject;
         }
     }
     //dd($subjects);
     return view('dashboard', compact('classes', 'totalClasses', 'totalSubjects', 'totalStaffs', 'totalStudents', 'user'));
 }
コード例 #2
0
 /**
  * Show the application welcome screen to the user.
  *
  * @return Response
  */
 public function index()
 {
     $user = \Auth::user();
     $id = $user->userId;
     $teacher = Teacher::where('teacherId', $id)->get();
     $student = Student::where('studentId', '=', $id)->get();
     $classe_id = "";
     if ($user->type === 'Student') {
         $class = Classe::where('name', $student[0]->class)->get();
         $classe_id = $class[0]->id;
     }
     //return $classe_id;
     $staff = Teacher::orderBy('lastname', 'asc')->get(['id', 'lastname', 'firstname', 'teacherId']);
     $classList = Classe::orderBy('name', 'asc')->lists('name', 'id');
     $subjectList = Subject::orderBy('name', 'asc')->lists('name', 'id');
     $assigned = [];
     $teacher = [];
     foreach (Teacher::lists('id') as $id) {
         $teacher = Teacher::findOrFail($id);
         foreach ($teacher->classes as $st) {
             $assignedClassId[] = $st->pivot->classe_id;
         }
         foreach ($teacher->subjects as $st) {
             $assignedSubjectId[] = $st->pivot->teacher_id;
         }
         $assignedClass = Classe::whereIn('id', $assignedClassId)->get();
         //return Classe::findOrFail(1)->subjects;
         foreach ($assignedClass as $ass) {
             $subjects[] = Classe::findOrFail($ass->id)->subjects;
         }
         foreach ($subjects[0] as $cl) {
             $subject[] = $cl->get(['id', 'name']);
         }
         /*return $allSubject = Subject::all(); //where('classe_id', 1)->get();
         
                    return $assignedClass[0]->id;*/
     }
     return view('profile', compact('user', 'student', 'class', 'assignedClass', 'subject', 'classe_id'));
 }
コード例 #3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id, Request $request)
 {
     $student = Student::find($id);
     if ($request->get('agree') == 1) {
         $student->delete();
         $student->subjects()->detach($id);
         return redirect()->route('students.index')->with('message', '<p class="alert alert-danger text-center">Student Deleted</p>');
     }
     return redirect('students');
 }