コード例 #1
0
 /**
  * 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');
 }
 /**
  * Re-upload the fee receipt of student
  *
  * @param Request $request
  * @return mixed
  */
 public function reUploadFeeReceipt(Request $request)
 {
     if ($request->hasFile('image')) {
         $this->validate($request, ['image' => 'image|required|max:2048'], ['image' => 'The file must be a valid image file.']);
         if ($request->file('image')->isValid()) {
             $image = $request->file('image');
             $rollNo = Auth::guard('student')->user()->rollNo;
             // Set the image parameters
             $imageQuality = 70;
             $imagePath = env('IMAGE_DIR') . '/feeReceipts/' . $rollNo . '.jpg';
             // Save the image
             Image::make($image->getRealPath())->save($imagePath, $imageQuality);
             // Update the request status
             TeacherRequest::where(['rollNo' => Auth::guard('student')->user()->rollNo])->update(['status' => 'new', 'remarks' => null]);
             return redirect()->back()->with('success');
         } else {
             return redirect()->back()->withErrors('Upload unsuccessful!!!');
         }
     }
 }