/** * Store a newly created branch in storage. * * @return Response */ public function store() { $validator = Validator::make($data = Input::all(), EAllowances::$rules, EAllowances::$messages); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $allowance = new EAllowances(); $allowance->employee_id = Input::get('employee'); $allowance->allowance_id = Input::get('allowance'); $allowance->allowance_amount = Input::get('amount'); $allowance->save(); Audit::logaudit('Employee Allowances', 'create', 'assigned: ' . $allowance->allowance_amount . ' to' . Employee::getEmployeeName(Input::get('employee'))); return Redirect::route('employee_allowances.index'); }
$destination = public_path() . '/migrations/'; $filename = str_random(12); $ext = Input::file('allowances')->getClientOriginalExtension(); $file = $filename . '.' . $ext; Input::file('allowances')->move($destination, $file); Excel::selectSheetsByIndex(0)->load(public_path() . '/migrations/' . $file, function ($reader) { $results = $reader->get(); foreach ($results as $result) { $name = explode(':', $result->employee); $employeeid = DB::table('employee')->where('personal_file_number', '=', $name[0])->pluck('id'); $allowanceid = DB::table('allowances')->where('allowance_name', '=', $result->allowance_type)->pluck('id'); $allowance = new EAllowances(); $allowance->employee_id = $employeeid; $allowance->allowance_id = $allowanceid; $allowance->allowance_amount = $result->amount; $allowance->save(); } }); } return Redirect::back()->with('notice', 'allowances have been succefully imported'); }); /* #################### IMPORT DEDUCTIONS ################################## */ Route::post('import/deductions', function () { if (Input::hasFile('deductions')) { $destination = public_path() . '/migrations/'; $filename = str_random(12); $ext = Input::file('deductions')->getClientOriginalExtension(); $file = $filename . '.' . $ext; Input::file('deductions')->move($destination, $file); Excel::selectSheetsByIndex(0)->load(public_path() . '/migrations/' . $file, function ($reader) { $results = $reader->get();