/**
  * Set registration process active / in-active
  *
  * @param $user
  * @return mixed
  */
 public function toggleRegistrationProcess($user)
 {
     if ($user === 'staff') {
         if ($this->isRegistrationActive('staff')) {
             unlink(storage_path() . '/app/activeForStaff');
             // Clear the tables
             Grade::truncate();
             ElectiveCount::truncate();
             TeacherRequest::truncate();
             AllocatedElective::truncate();
             AdminStaffRequest::truncate();
             HostelStaffRequest::truncate();
             CurrentStudentState::truncate();
             LibraryStaffRequest::truncate();
             ChiefWardenStaffRequest::truncate();
             Teacher::where('semNo', '>', '0')->update(['semNo' => null]);
         } else {
             touch(storage_path() . '/app/activeForStaff');
         }
     } else {
         if ($user === 'students') {
             if ($this->isRegistrationActive('student')) {
                 unlink(storage_path() . '/app/activeForStudents');
             } else {
                 touch(storage_path() . '/app/activeForStudents');
             }
         }
     }
     return redirect()->back();
 }
 /**
  * Delete a student registration request
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function deleteRequest(Request $request)
 {
     $rollNo = $request['rollNo'];
     // Delete the request from all associated tables
     AllocatedElective::where('rollNo', $rollNo)->delete();
     Grade::where('rollNo', $rollNo)->delete();
     HostelStaffRequest::destroy($rollNo);
     TeacherRequest::destroy($rollNo);
     AdminStaffRequest::destroy($rollNo);
     LibraryStaffRequest::destroy($rollNo);
     ChiefWardenStaffRequest::destroy($rollNo);
     // If the student has been verified, then decrement his/her semester
     if (CurrentStudentState::find($rollNo)->approved == true) {
         $student = Student::find($rollNo);
         $student->semNo = $student->semNo - 1;
         $student->save();
     }
     CurrentStudentState::destroy($rollNo);
     return redirect('/teachers/semesterRegistration/studentRequests/all');
 }
 /**
  * Get the registration form in PDF document
  *
  * @return string
  */
 public function getRegistrationForm()
 {
     if (Auth::guard('student')->user()->currentStudentState->approved == false) {
         return redirect()->back();
     }
     // Get the regular courses
     $courses = Course::where(['dCode' => Auth::guard('student')->user()->dCode, 'semNo' => $this->getCurrentStudentState()->semNo, 'openElective' => false, 'departmentElective' => false])->get();
     // Get electives if any
     $allocatedElectives = AllocatedElective::where('rollNo', Auth::guard('student')->user()->rollNo)->get();
     $count = 0;
     $registrationForm = App::make('snappy.pdf.wrapper');
     $registrationForm->loadView($this->registrationFormView, ['courses' => $courses, 'allocatedElectives' => $allocatedElectives, 'count' => $count])->setOption('margin-bottom', 10)->setOption('margin-top', 10);
     return $registrationForm->download(Auth::guard('student')->user()->rollNo . 'form.pdf');
 }