file_path; $import->import_type = $this->input('import-type'); $class = title_case($import->import_type); $classString = "App\\Importer\\{$class}Importer"; $importer = new $classString($filename); $import->field_map = request('column-mappings'); $import->save(); $fieldMappings=[]; if ($import->field_map) { // We submit as csv field: column, but the importer is happier if we flip it here. $fieldMappings = array_change_key_case(array_flip($import->field_map), CASE_LOWER); // dd($fieldMappings); } $importer->setCallbacks([$this, 'log'], [$this, 'progress'], [$this, 'errorCallback']) ->setUserId(Auth::id()) ->setUpdating($this->has('import-update')) ->setUsernameFormat('firstname.lastname') ->setFieldMappings($fieldMappings); // $logFile = storage_path('logs/importer.log'); // \Log::useFiles($logFile); $importer->import(); return $this->errors; } public function log($string) { // \Log::Info($string); } public function progress($count) { // Open for future return; } public function errorCallback($item, $field, $errorString) { $this->errors[$item->name][$field] = $errorString; } private $errors; }