public function show($id) { $articles = new Article(); $comment = new comment(); $article = $articles->where('article_id=' . $id)->find(); $comments = $comment->where('article_id=' . $id)->order('created_at')->select(); //$comments = $articles->relation(true)->find($id); $this->assign('article', $article); $this->assign('comments', $comments); $this->display('showArticle'); }
public function index() { Cas::getCurrentUser(); $user = session('cas_user'); $client = new \GuzzleHttp\Client(); // $response = $client->get('http://testserver.strathmore.edu:8082/dataservice/student/getStudent/'.$user); $responseStudent = file_get_contents('http://testserver.strathmore.edu:8082/dataservice/student/getStudent/' . $user); $responseStaff = file_get_contents('http://testserver.strathmore.edu:8082/dataservice/staff/getStaff/' . $user); // check to see if the logged in user is a student if ($responseStaff == '' && $responseStudent != '') { $student = json_decode($responseStudent, true); // check to see if student has already initiated the clearance process // if student has not requested to be cleared, he/she is taken to the clear request page $std = student::where('studentNo', '=', $user)->first(); // for testing, delete after test // if($student['studentNo'] == '78699'){ // return redirect()->intended('/cafeteria'); // } //If the query has a result ... if ($std === null) { return view('clearance.init')->with('student', $student); } else { $charge = charges::where('students_studentNo', '=', $user)->first(); $comment = comment::where('students_studentNo', '=', $user)->first(); return view('clearance.index')->with('std', $std)->with('charge', $charge)->with('comment', $comment); } } elseif ($responseStaff != '' && $responseStudent == '') { $staffMember = json_decode($responseStaff, true); $department_staff_belongs_to = $staffMember['departmentShortName']; $check_admin = DB::table('administrators')->where('payroll_number', '=', $staffMember['payroll_number'])->get(); if ($check_admin == null) { return "Not Authorized"; } else { // redirect the staff member to thier page depending on the school they admin.. $is_auth = DB::table('administrators')->where('payroll_number', '=', $staffMember['payroll_number'])->select('administrators.state')->get(); if ($is_auth != 'Authorised') { return "Not Authorized"; } else { if ($department_staff_belongs_to == 'FIT') { return redirect()->intended('/fit'); } else { if ($department_staff_belongs_to == "SLS") { return redirect()->intended('/sls'); } else { if ($department_staff_belongs_to == "SBS") { return redirect()->intended('/sbs'); } else { if ($department_staff_belongs_to == "SFAE") { return redirect()->intended('/sfae'); } else { if ($department_staff_belongs_to == "CTH") { return redirect()->intended('/cth'); } else { if ($department_staff_belongs_to == "SOA") { return redirect()->intended('/soa'); } else { if ($department_staff_belongs_to == "MTI") { return redirect()->intended('/mti'); } else { if ($department_staff_belongs_to == "SHSS") { return redirect()->intended('/shss'); } else { if ($department_staff_belongs_to == "SMC") { return redirect()->intended('/smc'); } else { // if the admin does not admin a school. Query by department name if ($department_staff_belongs_to == "CAFETERIA") { return redirect()->intended('/cafeteria'); } else { if ($department_staff_belongs_to == "LIBRARY") { return redirect()->intended('/library'); } else { if ($department_staff_belongs_to == "FINANCE") { return redirect()->intended('/finance'); } else { if ($department_staff_belongs_to == "FINANCIAL AID") { return redirect()->intended('/financialAid'); } else { if ($department_staff_belongs_to == "GAMES") { return redirect()->intended('/games'); } else { if ($department_staff_belongs_to == "EXTRA CURRICULAR ACTIVITIES") { return redirect()->intended('/extraCurricularActivities'); } } } } } } } } } } } } } } } } } } }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $user = Auth::user()->regNo; // Attempts to get details of the student who is logged in. $std = student::where('studentNo', '=', $user)->first(); // If the query has a result ... if ($std != null) { $charge = charges::where('students_studentNo', '=', $user)->first(); $comment = comment::where('students_studentNo', '=', $user)->first(); if ($std->state == 'Inactive') { return view('clearance.init'); } else { return view('clearance.index')->with('std', $std)->with('charge', $charge)->with('comment', $comment); //return $charge; } } else { // For a null result in the above $std query. This block of code executes. $admin = DB::table('schools')->where('schools.administrator', '=', $user)->pluck('department_name'); if ($admin == "FIT") { return redirect()->intended('/fit'); } else { if ($admin == "SLS") { return redirect()->intended('/sls'); } else { if ($admin == "SBS") { return redirect()->intended('/sbs'); } else { if ($admin == "SFAE") { return redirect()->intended('/sfae'); } else { if ($admin == "CTH") { return redirect()->intended('/cth'); } else { if ($admin == "SOA") { return redirect()->intended('/soa'); } else { if ($admin == "MTI") { return redirect()->intended('/mti'); } else { if ($admin == "SHSS") { return redirect()->intended('/shss'); } else { if ($admin == "SMC") { return redirect()->intended('/smc'); } else { if ($admin == "Cafeteria") { return redirect()->intended('/cafeteria'); } else { if ($admin == "Library") { return redirect()->intended('/library'); } else { if ($admin == "Finance") { return redirect()->intended('/finance'); // return Redirect::route('/finance', array('id' => $admin)); } else { if ($admin == "Financial Aid") { return redirect()->intended('/financialAid'); } else { if ($admin == "Games") { return redirect()->intended('/games'); } else { if ($admin == "Extra-curricular") { return redirect()->intended('/extraCurricularActivities'); } else { /* * For test purposes! Nerds ONLY!! ;-) * */ return redirect()->intended('/vc'); } } } } } } } } } } } } } } } } }