public function SupervisionEditConfirmStudentReq(Request $requests, $user_id, $student_id, $request_id) { $reason = Input::get('reason'); $new_comment = Input::get('supervisor_comment'); $new_confirmation = Input::get('supervisor_confirmation'); $old_comment = AddRequest::where('id', $request_id)->where('user_id', $student_id)->pluck('supervisor_comment'); if ($reason === '' and $new_comment === '' and $new_confirmation === 'Confirmed') { Session::flash('failed', "Nothing was changed, please check that you're actually updating something"); return back()->withInput(); } elseif ($reason != '' and $new_comment === '' and $new_confirmation === 'Confirmed') { Session::flash('failed', "You're trying to provide reason where you have not make any changes, Please make sure you're actually changing something to be able to provide reason"); return back()->withInput(); } elseif ($new_comment != '' and $reason === '') { if (UserMod::where('id', $user_id)->where('role', '=', 'Lecturer')->exists() and PhDStudent::where('supervisor_id', $user_id)->where('user_id', $student_id)->exists() and AddRequest::where('id', $request_id)->where('user_id', $student_id)->where('supervisor_confirmation', '=', 'Confirmed')->exists()) { $data = array('supervisor_comment' => '[Changed] - New Comment: ' . $requests->input('supervisor_comment'), 'supervisor_confirmation' => $requests->input('supervisor_confirmation')); $ch = AddRequest::where('id', $request_id)->where('user_id', $student_id)->update($data); if ($ch > 0) { Session::flash('success', "Your confirmation was successfully processed!"); return back()->withInput(); } else { Session::flash('failed', "Failed!"); return back()->withInput(); } } else { Session::flash('failed', "Something went wrong, please try again!"); return back()->withInput(); } } elseif ($new_comment === '' and $reason != '') { if (UserMod::where('id', $user_id)->where('role', '=', 'Lecturer')->exists() and PhDStudent::where('supervisor_id', $user_id)->where('user_id', $student_id)->exists() and AddRequest::where('id', $request_id)->where('user_id', $student_id)->where('supervisor_confirmation', '=', 'Confirmed')->exists()) { $data = array('supervisor_comment' => '[Changed] Reason: ' . $requests->input('reason') . ' - No New Comment Given' . $requests->{$old_comment}, 'supervisor_confirmation' => $requests->input('supervisor_confirmation')); $ch = AddRequest::where('id', $request_id)->where('user_id', $student_id)->update($data); if ($ch > 0) { Session::flash('success', "Your confirmation was successfully processed!"); return back()->withInput(); } else { Session::flash('failed', "Failed!"); return back()->withInput(); } } else { Session::flash('failed', "Something went wrong, please try again!"); return back()->withInput(); } } elseif ($new_comment === '' and $reason === '' and $new_confirmation != 'Confirmed') { if (UserMod::where('id', $user_id)->where('role', '=', 'Lecturer')->exists() and PhDStudent::where('supervisor_id', $user_id)->where('user_id', $student_id)->exists() and AddRequest::where('id', $request_id)->where('user_id', $student_id)->where('supervisor_confirmation', '=', 'Confirmed')->exists()) { $data = array('supervisor_comment' => '[Changed] Reason: NOT GIVEN - No New Comment Given', 'supervisor_confirmation' => $requests->input('supervisor_confirmation')); $ch = AddRequest::where('id', $request_id)->where('user_id', $student_id)->update($data); if ($ch > 0) { Session::flash('success', "Your confirmation was successfully processed!"); return back()->withInput(); } else { Session::flash('failed', "Failed!"); return back()->withInput(); } } else { Session::flash('failed', "Something went wrong, please try again!"); return back()->withInput(); } } else { if (UserMod::where('id', $user_id)->where('role', '=', 'Lecturer')->exists() and PhDStudent::where('supervisor_id', $user_id)->where('user_id', $student_id)->exists() and AddRequest::where('id', $request_id)->where('user_id', $student_id)->where('supervisor_confirmation', '=', 'Confirmed')->exists()) { $data = array('supervisor_comment' => '[Changed] Reason: ' . $requests->input('reason') . ' - New Comment: ' . $requests->input('supervisor_comment'), 'supervisor_confirmation' => $requests->input('supervisor_confirmation')); $ch = AddRequest::where('id', $request_id)->where('user_id', $student_id)->update($data); if ($ch > 0) { Session::flash('success', "Your confirmation was successfully processed!"); return back()->withInput(); } else { Session::flash('failed', "Failed!"); return back()->withInput(); } } else { Session::flash('failed', "Something went wrong, please try again!"); return back()->withInput(); } } }
public function destroyPhDUsr($id) { $PhdInfo = PhDStudent::where('user_id', $id); $User = UserMod::where('role', '=', 'PHD Student')->find($id); $PhdInfo->delete(); $User->delete(); Session::flash('phd_deleted', "User was successfully deleted"); return redirect('Admin/Users/Modify/PhdStudent'); }