public function saveTimeline() { $id = Input::get('id'); if ($id == 'new') { $created_at = date('Y-m-d H:i:s'); $save = DB::table('timeline')->insert(array('phase_id' => Input::get('phase_id'), 'event' => Input::get('event'), 'duration' => Input::get('duration'), 'order' => Input::get('order'), 'row_creator' => Auth::user()->getName(), 'row_updator' => Auth::user()->getName(), 'created_at' => $created_at, 'updated_at' => $created_at)); //Get Mother Id $motherId = DB::table('timeline')->where('created_at', $created_at)->where('event', Input::get('event'))->pluck('id'); //Call docsUpload function $tableName = 'timeline'; $motherId = $motherId; $fieldName = 'docs'; $docType = 'pdf'; // return Input::hasFile($fieldName); CommonFunction::docsUpload($tableName, $motherId, $fieldName, $docType); return Redirect::back()->with('message', 'Event Successfully Saved!'); } else { $created_at = date('Y-m-d H:i:s'); $save = DB::table('timeline')->where('id', $id)->update(array('event' => Input::get('event'), 'duration' => Input::get('duration'), 'order' => Input::get('order'), 'row_updator' => Auth::user()->getName(), 'updated_at' => $created_at)); //Get Mother Id $motherId = $id; //Call docsUpload function $tableName = 'timeline'; $motherId = $motherId; $fieldName = 'docs'; $docType = 'pdf'; // return Input::hasFile($fieldName); CommonFunction::docsUpload($tableName, $motherId, $fieldName, $docType); return Redirect::back()->with('message', 'Event Successfully Updated!'); } }