public function getImageAttribute($image) { if (empty($image)) { return ''; } $fileSystem = new FileSystem(); return $fileSystem->getPathToFile($image); }
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', 'Импорт прошел успешно'); }