Ejemplo n.º 1
0
 /**
  * return courses of the given school
  * This Method is used in user Registration
  * @return Response
  */
 public function getCourseFromSchool(Request $request)
 {
     if (!isset($request->school)) {
         return;
     }
     //Validate the Request
     $this->validate($request, ['school' => 'required']);
     $courseSchool = CourseSchool::where('school_id', $request->school)->orderBy('course_id')->get();
     foreach ($courseSchool as $key => $value) {
         //$course[] ='<option value="'.$value->id.'">'.$value->course->name . " ". $value->course->division.'</option>';
         $course[$key]['course_school_id'] = $value->id;
         $course[$key]['course'] = $value->course->id;
         $course[$key]['name'] = $value->course->name;
         $course[$key]['division'] = $value->course->division;
     }
     if (isset($course)) {
         return collect($course)->toJson();
     } else {
         return;
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     if (Auth::user()->hasRole('Staff')) {
         $staffTimetable = StaffTimetable::where('staff_id', Auth::user()->id)->orderBy('period')->get();
         return view('timetable/timetable')->with('staffTimetable', $staffTimetable);
     }
     if (Auth::user()->hasRole('Student')) {
         $studentTimetable = StudentTimetable::where('course_school_id', Auth::user()->details->course_school_id)->orderBy('period')->get();
         return view('timetable/timetable')->with('studentTimetable', $studentTimetable);
     }
     if (Auth::user()->hasRole('Foundation') || Auth::user()->hasRole('SuperAdmin')) {
         $courseSchool = CourseSchool::where('school_id', Auth::user()->school_id)->orderBy('course_id')->get();
         foreach ($courseSchool as $key => $value) {
             $course[$key]['course_school_id'] = $value->id;
             $course[$key]['course'] = $value->course->id;
             $course[$key]['name'] = $value->course->name;
             $course[$key]['division'] = $value->course->division;
         }
         if (isset($course)) {
             return view('timetable/timetable')->with('Course', $course);
         }
     }
     return redirect('home');
 }
Ejemplo n.º 3
0
 /**
  * Get the course
  */
 public function school()
 {
     return CourseSchool::find($this->course_school_id)->school();
 }