Exemplo n.º 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'));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id, Request $request)
 {
     $user = \Auth::user();
     $teacher = Teacher::find($id);
     if ($request->get('agree') == 1) {
         $teacher->delete();
         return redirect()->route('teachers.index')->with('message', '<p class="alert alert-danger text-center">teacher Deleted</p>');
     }
     return redirect('teachers');
 }