Пример #1
0
 public function setImageAttribute(UploadedFile $image)
 {
     /**
      * @var $file UploadedFile
      */
     if ($image) {
         $fileSystem = new FileSystem();
         $fileName = $fileSystem->upload($image);
         $this->attributes['image'] = $fileName;
     }
 }
 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', 'Импорт прошел успешно');
 }