public function saveAs(Request $request) { // retrieve all records as collection $records = IndustryExtension1::select('report_date_id', 'institution_id', 'subsector_id', 'identified_technologies', 'benchmarked_technologies', 'proper_documentation', 'prototype', 'competent_entrepreneurs', 'transferred', 'capital', '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 IndustryExtension1::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-1'); }
public function ie_technologies_identified() { $result = IndustryExtension1::select(DB::raw('sum(identified_technologies) as identified_technologies, sum(transferred) as transferred_technologies'))->where('report_date_id', $this->report_date_id)->where('institution_id', $this->institution_id)->get(); return $result; }