public function mapCSV($files) { $data = []; foreach ($files as $entityType => $filename) { if ($entityType === ENTITY_CLIENT) { $columns = Client::getImportColumns(); $map = Client::getImportMap(); } else { $columns = Invoice::getImportColumns(); $map = Invoice::getImportMap(); } // Lookup field translations foreach ($columns as $key => $value) { unset($columns[$key]); $columns[$value] = trans("texts.{$value}"); } array_unshift($columns, ' '); $data[$entityType] = $this->mapFile($entityType, $filename, $columns, $map); if ($entityType === ENTITY_CLIENT) { if (count($data[$entityType]['data']) + Client::scope()->count() > Auth::user()->getMaxNumClients()) { throw new Exception(trans('texts.limit_clients', ['count' => Auth::user()->getMaxNumClients()])); } } } return $data; }