/** * Display a listing of the resource. * * @return Response */ public function index() { $user = \Auth::user(); $count = 1; $students = Student::all(); return view('admin.students.index', compact('students', 'count', 'user')); }
/** * 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')); }