/** * Add fee and hostel details of the student and * send the corresponding approval requests * * @param Request $request * @return mixed */ public function addFeeAndHostelDetails(Request $request) { $currentStudentState = $this->getCurrentStudentState(); /* * Check if the fee receipt image is present. If present, then upload * the image and send the approval request to the teacher, otherwise * send the approval request to accounts branch for verification */ 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 image path in the database * and send the request to the teacher */ TeacherRequest::create(['rollNo' => Auth::guard('student')->user()->rollNo, 'semNo' => $currentStudentState->semNo, 'status' => 'new', 'imagePath' => $imagePath]); } else { return redirect()->back()->withErrors('Upload unsuccessful!!!'); } } else { $loanCase = $currentStudentState->loanCase; // Send the request to accounts branch AdminStaffRequest::create(['rollNo' => Auth::guard('student')->user()->rollNo, 'status' => 'new', 'loanCase' => $loanCase]); } /* * Check if the hostelId is present. If present, then send the approval request to the * concerned hostel, otherwise send the approval request to chief warden office */ if ($request->has('hostelId')) { $currentStudentState->hostelId = $request['hostelId']; $currentStudentState->save(); // Send the request to the concerned hostel HostelStaffRequest::create(['rollNo' => Auth::guard('student')->user()->rollNo, 'hostelId' => $request['hostelId'], 'status' => 'new']); } else { // Send the request to chief warden office for approval ChiefWardenStaffRequest::create(['rollNo' => Auth::guard('student')->user()->rollNo, 'status' => 'new']); } // Send the request to library for approval LibraryStaffRequest::create(['rollNo' => Auth::guard('student')->user()->rollNo, 'status' => 'new']); $currentStudentState->step = 2; $currentStudentState->save(); // Now redirect to next step return redirect('/students/semesterRegistration/courseDetails'); }