/**
  * Update the specified resource in storage.
  *
  * @return Response
  */
 public function update(Request $request)
 {
     //Initialize input properties
     if ($request->filing_type == 'RFC') {
         $validator = Validator::make($request->all(), ['approver_response' => 'required', 'notes' => 'required', 'remarks' => 'required']);
     } else {
         if ($request->filing_type == 'RFR' || $request->filing_type == 'QAC') {
             $validator = Validator::make($request->all(), ['approver_response' => 'required', 'remarks' => 'required']);
         }
     }
     //Redirect back if with input errors
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     //Initialization
     $approver_response = $request->approver_response;
     $EASRequest = new EASRequest();
     $user_id = trim(Auth::user()->app_code);
     if ($approver_response == 'Denied' || $approver_response == 'Signed' || $approver_response == 'On-Hold') {
         //Update the request
         $EASRequest->respondRequest($request->request_code, $approver_response, $request->approver_level, trim($request->remarks));
         //Get updated details
         $data = [];
         $data['details'] = $EASRequest->getRequestDetails($request->request_code, $user_id);
         $data['details']['approver_level'] = $request->approver_level;
         //Email Appropriate recipients
         $mail = new EmailController();
         $mail->send($data['details'], $approver_response);
         return $this->show(trim($data['details']['rfc_code']));
     } else {
         if ($approver_response == 'Edit') {
             //Update the request
             $EASRequest->updateRequest($request->request_code, $user_id, $request->all(), $request->filing_type);
             //Get updated details
             $data = [];
             $data['details'] = $EASRequest->getRequestDetails($request->request_code, $user_id);
             //Email Appropriate recipients
             $mail = new EmailController();
             $mail->send($data['details'], $approver_response);
             return $this->edit(trim($data['details']['rfc_code']), $request->filing_type, 'update');
         }
     }
 }