/** * Store a newly created branch in storage. * * @return Response */ public function store() { $validator = Validator::make($data = Input::all(), ERelief::$rules, ERelief::$messages); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $rel = new ERelief(); $rel->employee_id = Input::get('employee'); $rel->relief_id = Input::get('relief'); $rel->relief_amount = Input::get('amount'); $rel->save(); return Redirect::route('employee_relief.index'); }
$destination = public_path() . '/migrations/'; $filename = str_random(12); $ext = Input::file('reliefs')->getClientOriginalExtension(); $file = $filename . '.' . $ext; Input::file('reliefs')->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'); $reliefid = DB::table('relief')->where('relief_name', '=', $result->relief_type)->pluck('id'); $relief = new ERelief(); $relief->employee_id = $employeeid; $relief->relief_id = $reliefid; $relief->relief_amount = $result->amount; $relief->save(); } }); } return Redirect::back()->with('notice', 'reliefs have been succeffully imported'); }); /* #################### IMPORT ALLOWANCES ################################## */ Route::post('import/allowances', function () { if (Input::hasFile('allowances')) { $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();