public function ie_mse_operators()
 {
     $result = IndustryExtension2::select(DB::raw('sum(starter_enterprise) as starter_enterprise,
             sum(starter_mse_operator_male) as starter_mse_operator_male,
             sum(starter_mse_operator_female) as starter_mse_operator_female,
             sum(starter_mse_operator_supported_male) as starter_mse_operator_supported_male,
             sum(starter_mse_operator_supported_female) as starter_mse_operator_supported_female,
             sum(advance_enterprise) as advance_enterprise,
             sum(advance_mse_operator_male) as advance_mse_operator_male,
             sum(advance_mse_operator_female) as advance_mse_operator_female,
             sum(advance_mse_operator_supported_male) as advance_mse_operator_supported_male,
             sum(advance_mse_operator_supported_female) as advance_mse_operator_supported_female,
             sum(competent_enterprise) as competent_enterprise,
             sum(competent_mse_operator_male) as competent_mse_operator_male,
             sum(competent_mse_operator_female) as competent_mse_operator_female,
             sum(competent_mse_operator_supported_male) as competent_mse_operator_supported_male,
             sum(competent_mse_operator_supported_female) as competent_mse_operator_supported_female'))->where('report_date_id', $this->report_date_id)->where('institution_id', $this->institution_id)->get();
     return $result;
 }
 public function saveAs(Request $request)
 {
     // retrieve all records as collection
     $records = IndustryExtension2::select('report_date_id', 'institution_id', 'subsector_id', 'starter_enterprise', 'starter_mse_operator_male', 'starter_mse_operator_female', 'starter_mse_operator_supported_male', 'starter_mse_operator_supported_female', 'advance_enterprise', 'advance_mse_operator_male', 'advance_mse_operator_female', 'advance_mse_operator_supported_male', 'advance_mse_operator_supported_female', 'competent_enterprise', 'competent_mse_operator_male', 'competent_mse_operator_female', 'competent_mse_operator_supported_male', 'competent_mse_operator_supported_female', 'remarks')->where('report_date_id', $request->report_date_id_source)->get();
     if (count($records) > 0) {
         // update report date id to target report date id
         foreach ($records as $rec) {
             $rec->report_date_id = $request->report_date_id_target;
         }
         // insert into the table
         IndustryExtension2::insert($records->toArray());
         // send a flash message
         $request->session()->flash('alert-success', 'Save as operation was successful!');
     } else {
         // send a flash message
         $request->session()->flash('alert-danger', 'Save as operation failed! No records found from source.');
     }
     return redirect('industry-extension-2');
 }