/** * * Map first if necessary, * * STEP FIVE. * * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View * @throws FireflyException */ public function map() { // Make sure all fields we need are accounted for. $fields = ['csv-file', 'csv-date-format', 'csv-has-headers', 'csv-map', 'csv-roles']; if (!$this->wizard->sessionHasValues($fields)) { Session::flash('warning', 'Could not recover upload.'); return redirect(route('csv.index')); } /* * The "options" array contains all options the user has * per column, where the key represents the column. * * For each key there is an array which in turn represents * all the options available: grouped by ID. * * options[column index] = [ * field id => field identifier. * ] */ try { $options = $this->wizard->showOptions($this->data->getMap()); } catch (FireflyException $e) { return view('error', ['message' => $e->getMessage()]); } // After these values are prepped, read the actual CSV file $reader = $this->data->getReader(); $map = $this->data->getMap(); $hasHeaders = $this->data->hasHeaders(); $values = $this->wizard->getMappableValues($reader, $map, $hasHeaders); $map = $this->data->getMap(); $mapped = $this->data->getMapped(); $subTitle = trans('firefly.csv_map_values'); return view('csv.map', compact('map', 'options', 'values', 'mapped', 'subTitle')); }