From 2ecebc1a3cfc7ad8b4921091ebefa26ab1670b35 Mon Sep 17 00:00:00 2001 From: didier Date: Fri, 4 Oct 2024 18:21:57 +0200 Subject: [PATCH] fix import bug --- .../Controllers/MeasureImportController.php | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/app/Http/Controllers/MeasureImportController.php b/app/Http/Controllers/MeasureImportController.php index b2fd6c38..ccc71497 100644 --- a/app/Http/Controllers/MeasureImportController.php +++ b/app/Http/Controllers/MeasureImportController.php @@ -99,23 +99,23 @@ function ($e) use ($model) { ); // Get full path $fileName = Storage::disk('local')->path($file); - - // XLSX - $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx(); - $reader->setReadDataOnly(true); - $spreadsheet = $reader->load($fileName); - - $sheet = $spreadsheet->getSheet($spreadsheet->getFirstSheetIndex()); - $data = $sheet->toArray(); - - if ($this->canImportFromFile($data, $request->has('clean'), $errors)) { - // Clear database - if ($request->has('clean')) { - $this->clean(); - $errors->push('Database cleared'); - } - $this->importFromFile($data, $errors); + } + + // XLSX + $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx(); + $reader->setReadDataOnly(true); + $spreadsheet = $reader->load($fileName); + + $sheet = $spreadsheet->getSheet($spreadsheet->getFirstSheetIndex()); + $data = $sheet->toArray(); + + if ($this->canImportFromFile($data, $request->has('clean'), $errors)) { + // Clear database + if ($request->has('clean')) { + $this->clean(); + $errors->push('Database cleared'); } + $this->importFromFile($data, $errors); } } finally { if ($request->file()) {