/** * Update the Profile - Personal Details. * * @Patch("profile/personal-details") * @Patch("pim/employee-list/{id}/personal-details") * * @param PersonalDetailsRequest $request * @return \Illuminate\Http\RedirectResponse * @author Bertrand Kintanar */ public function update(PersonalDetailsRequest $request) { $id = $request->get('id'); $employee_id = $request->get('employee_id'); $employee = $this->employee->whereId($id)->first(); if (!$employee) { return redirect()->to($request->path())->with('danger', UNABLE_UPDATE_MESSAGE); } // If user is trying to update the employee_id to a used employee_id. $original_employee_id = $this->employee->whereEmployeeId($employee_id)->pluck('id'); if ($id != $original_employee_id && !is_null($original_employee_id)) { $path = $request->path(); // pim/employee-list/{id}/personal-details if ($request->is('*pim/*')) { $path = explode('/', $path); $path[2] = $employee->employee_id; $path = implode('/', $path); } return redirect()->to($path)->with('danger', EMPLOYEE_ID_IN_MESSAGE); } try { $employee->update($request->all()); } catch (Exception $e) { return redirect()->to($request->path())->with('danger', UNABLE_UPDATE_MESSAGE); } return redirect()->to($request->path())->with('success', SUCCESS_UPDATE_MESSAGE); }
/** * Execute the console command. * * @author Bertrand Kintanar */ public function handle() { $csv = Reader::createFromPath(storage_path() . '/timelog.csv'); $csv->setOffset(1); $data = $csv->query(); foreach ($data as $lineIndex => $row) { $employee = Employee::whereEmployeeId($row[1])->first(); if ($employee) { $employee->face_id = $row[0]; $employee->save(); $this->info($employee); Log::info($employee); } } }