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'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(StaffAssignRequest $request)
 {
     $teacher = Teacher::findOrFail($request->input('teacher_id'));
     //$teacher->classes()->attach($request->input('classe_id'))->subjects()->attach($request->input('subject_id'));
     $teacher->classes()->attach($request->input('classe_id'));
     $teacher->subjects()->attach($request->input('subject_id'));
     return redirect()->route('staffAssign.index')->with('message', '<p class="alert alert-success text-center">Class and Subject Assigned to Staff</p>');
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $user = Auth::user();
     $staff = Teacher::all();
     $classList = Classe::lists('name', 'id');
     $subjectList = Subject::lists('name', 'id');
     $subjectAssigned = SubjectAssigned::all();
     return view('Admin.subjectAssigned.index', compact('subjectList', 'classList', 'staff', 'user', 'assignedClass', 'subjectAssigned'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(QuestionRequest $request, $id, $subjectId)
 {
     $question = new Question($request->all());
     $teacher = Teacher::where('teacherId', Auth::user()->userId)->first();
     $teacher->questions()->save($question);
     $myanswer = $request['answer'];
     $myanswer = $request[$myanswer];
     $answer = new Answer();
     $answer->answer = $myanswer;
     $question->answer()->save($answer);
     return redirect()->route("classes.subjects.questions.index", [$id, $subjectId])->with(['message' => '<p class="alert alert-success">Question Added</p>', 'user']);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(QuestionRequest $request)
 {
     $question = new Question($request->all());
     $teacher = Teacher::where('teacherId', Auth::user()->userId)->first();
     //dd($teacher->questions());
     $teacher->questions()->save($question);
     $myanswer = $request['answer'];
     $myanswer = $request[$myanswer];
     $answer = new Answer();
     $answer->answer = $myanswer;
     $question->answer()->save($answer);
     /*$input = $request->all();
     
     		Question::create($input);*/
     return redirect()->back()->with('message', '<span class="alert alert-success">Question Created</span>');
 }
 /**
  * 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'));
 }
 /**
  * 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');
 }