/**
  * Display the specified resource.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function show(Request $request, $id)
 {
     if ($request->ajax()) {
         $teacher = Teacher::find($id);
         return response($teacher);
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function show($id)
 {
     //
     $teacher = Teacher::find($id);
     $teachers = Teacher::topN(6);
     $articles = Article::topN(6);
     $categories_in_pane = ArticleCategory::all();
     return response()->view('site.teacher', array('teacher' => $teacher, 'teachers' => $teachers, 'other_articles' => $articles, 'categories_in_pane' => $categories_in_pane));
 }
 public function destroy($teacher_id)
 {
     $teacher = Teacher::find($teacher_id);
     if ($teacher) {
         $teacher->courses()->detach();
         $teacher->delete();
         return $this->createSuccessResponse("The teacher with id {$teacher->id} has been updated.", 200);
     }
     return $this->createErrorMessage("The teacher with the specified id does not exists.", 404);
 }
 public function destroy($teacher_id)
 {
     $teacher = Teacher::find($teacher_id);
     if ($teacher) {
         $courses = $teacher->courses;
         if (sizeof($courses) > 0) {
             return $this->createErrorResponse('You can\'t remove a teacher with active courses. Please remove those courses first', 409);
         }
         $teacher->delete();
         return $this->createSuccessResponse("The teacher with id {$teacher_id} has been removed", 200);
     }
     return $this->createErrorResponse('The teacher with the specified id does not exists');
 }
 /**
  * Update the password
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  * @throws \Illuminate\Foundation\Validation\ValidationException
  */
 public function updatePassword(Request $request)
 {
     // Validate the password length
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     // Get the currently logged teacher
     $teacher = Teacher::find(Auth::guard('teacher')->user()->facultyId);
     $newPassword = $request['password'];
     $teacher->password = bcrypt($newPassword);
     $teacher->firstLogin = false;
     $teacher->save();
     return redirect('/teachers/home');
 }
 public function destroy($teacher_id, $course_id)
 {
     $teacher = Teacher::find($teacher_id);
     if ($teacher) {
         $course = Course::find($course_id);
         if ($course) {
             if ($teacher->courses()->find($course_id)) {
                 $course->students()->detach();
                 $course->delete();
                 return $this->createSuccessResponse("The course with id {$course_id} was removed", 200);
             }
             return $this->createSuccessResponse("The course with id {$course_id} was updated", 200);
         }
         return $this->createErrorResponse("The course with the id {$course_id} does not exists", 404);
     }
     return $this->createErrorResponse("The teacher with the id {$teacher_id} does not exists", 404);
 }
Example #7
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     DB::connection()->getPdo()->beginTransaction();
     try {
         $teachers = Teacher::find($id);
         $resId = $teachers->photo;
         $teachers->delete();
         UploadedRes::destroy($resId);
         DB::connection()->getPdo()->commit();
         return response()->json(array("ok" => 1), 200, ['Content-Type:text/json;charset=UTF-8']);
     } catch (\PDOException $e) {
         DB::connection()->getPdo()->rollback();
         return response()->json(array("ok" => 0), 500, ['Content-Type:text/json;charset=UTF-8']);
     }
 }
 /**
  * Update user password
  *
  * @param Request $request
  * @return mixed
  */
 public function updatePassword(Request $request)
 {
     // Get the logged in user
     $teacher = Teacher::find(Auth::guard('teacher')->user()->facultyId);
     $newPassword = $request['password'];
     // Validate the password
     $this->validate($request, ['password' => 'required|min:8']);
     // Save updated password
     $teacher->password = bcrypt($newPassword);
     $teacher->save();
     return redirect()->back()->with('status', 'Success');
 }
Example #9
0
 public function showTeacher($id)
 {
     $teacher = Teacher::find($id);
     if (empty($teacher)) {
         abort(404);
     }
     $section = 'szdw';
     $sort = $teacher->taxonomy;
     $data = ['section' => $section];
     $data = self::equipSort($data, $section, $sort);
     $data['pageTitle'] = $teacher->name;
     $data['name'] = $teacher->name;
     $data['description'] = $teacher->description;
     $data['picture'] = $teacher->picture;
     return view('teacher', $data);
 }
 /**
  * Set / update teachers semester
  *
  * @param Request $request
  * @return mixed
  */
 public function addSemester(Request $request)
 {
     if (!$this->isRegistrationActive('staff')) {
         return view($this->inactiveView);
     }
     $this->validate($request, ['semNo' => 'required|numeric|min:1|unique:teachers,semNo,NULL,id,dCode,' . Auth::guard('teacher')->user()->dCode], ['unique' => 'This semester is already allocated']);
     $semNo = $request['semNo'];
     $teacher = Teacher::find(Auth::guard('teacher')->user()->facultyId);
     $teacher->semNo = $semNo;
     $teacher->save();
     return redirect()->back();
 }
 /**
  * PUT
  * Assign a Course to Teacher
  * @param Request $request
  */
 public function assignCourseToTeacher(Request $request)
 {
     if ($request->ajax()) {
         $course = Course::where('code', $request->input('code'))->first();
         $course->isAssigned = 1;
         $teacher = Teacher::find($request->input('teacher_id'));
         $course->teacher()->associate($teacher);
         $course->save();
         $remaining_credit = $request->input('remaining_credit') - $request->input('credit');
         $teacher->remaining_credit = $remaining_credit;
         $teacher->save();
         $request->session()->flash('status', 'Course was assigned to Teacher successfully!');
         return response()->json(['message' => 'Successful']);
     }
 }
Example #12
0
 public function teacherDelete()
 {
     $v = Validator::make(Input::all(), ['id' => 'required|numeric']);
     if ($v->fails()) {
         return View::getBadRequstView($v->messages());
     } else {
         if (Teacher::find(Input::get('id')) == null) {
             return View::getBadRequstView('no teach of this id. id is ' . Input::get('id'));
         }
     }
     Teacher::find(Input::get('id'))->delete();
     return redirect('/admin/teacher');
 }