public function postImport(Request $request, SpoutImporter $importer, FileSystem $fileSystem)
 {
     set_time_limit(0);
     $excelFile = $request->file('excel');
     if (!$excelFile) {
         return $this->redirectWithFileError();
     }
     $fileName = $fileSystem->upload($excelFile);
     $pathToExcel = realpath(public_path($fileSystem->getPathToFile($fileName)));
     if ($pathToExcel === false) {
         return $this->redirectWithFileError();
     }
     //        Artisan::call('excel:import', [
     //                'path' => $pathToExcel,
     //                '--queue' => 'default',
     //            ]);
     try {
         $importer->import($pathToExcel);
     } catch (\Exception $ex) {
         return $this->redirectWithFileError();
     }
     //        $this->dispatch(new ExcelImportJob($pathToExcel));
     return redirect()->action('ChildrenController@getImport')->with('flash_message', 'Импорт прошел успешно');
 }
Esempio n. 2
0
 private function spoutExcelImporter($pathToExcel)
 {
     $importer = new SpoutImporter();
     $importer->import($pathToExcel);
 }