diff --git a/app/Abstracts/Import.php b/app/Abstracts/Import.php
index ebd689d2f..e628eba50 100644
--- a/app/Abstracts/Import.php
+++ b/app/Abstracts/Import.php
@@ -15,11 +15,12 @@ use Maatwebsite\Excel\Concerns\SkipsEmptyRows;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithChunkReading;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
+use Maatwebsite\Excel\Concerns\WithLimit;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithValidation;
use PhpOffice\PhpSpreadsheet\Shared\Date as ExcelDate;
-abstract class Import implements HasLocalePreference, ShouldQueue, SkipsEmptyRows, WithChunkReading, WithHeadingRow, WithMapping, WithValidation, ToModel
+abstract class Import implements HasLocalePreference, ShouldQueue, SkipsEmptyRows, WithChunkReading, WithHeadingRow, WithLimit, WithMapping, WithValidation, ToModel
{
use Importable, ImportHelper;
@@ -69,7 +70,12 @@ abstract class Import implements HasLocalePreference, ShouldQueue, SkipsEmptyRow
public function chunkSize(): int
{
- return 100;
+ return config('excel.imports.chunk_size');
+ }
+
+ public function limit(): int
+ {
+ return config('excel.imports.row_limit');
}
public function isNotValid($row)
diff --git a/app/Http/Requests/Common/Import.php b/app/Http/Requests/Common/Import.php
index 7b8c811e9..6756cb973 100644
--- a/app/Http/Requests/Common/Import.php
+++ b/app/Http/Requests/Common/Import.php
@@ -24,7 +24,7 @@ class Import extends FormRequest
public function rules()
{
return [
- 'import' => 'required|file|extension:xls,xlsx',
+ 'import' => 'required|file|extension:' . config('excel.imports.extensions'),
];
}
}
diff --git a/config/excel.php b/config/excel.php
index 1b34c6fcf..a0ec03511 100644
--- a/config/excel.php
+++ b/config/excel.php
@@ -13,7 +13,7 @@ return [
| Here you can specify how big the chunk should be.
|
*/
- 'chunk_size' => 100,
+ 'chunk_size' => env('EXCEL_EXPORTS_CHUNK_SIZE', 100),
/*
|--------------------------------------------------------------------------
@@ -42,6 +42,12 @@ return [
'imports' => [
+ 'chunk_size' => env('EXCEL_IMPORTS_CHUNK_SIZE', 100),
+
+ 'row_limit' => env('EXCEL_IMPORTS_ROW_LIMIT', 1000),
+
+ 'extensions' => env('EXCEL_IMPORTS_EXTENSIONS', 'xls,xlsx'),
+
'read_only' => true,
'heading_row' => [
diff --git a/resources/lang/en-GB/import.php b/resources/lang/en-GB/import.php
index d4a326edf..69dc8c641 100644
--- a/resources/lang/en-GB/import.php
+++ b/resources/lang/en-GB/import.php
@@ -4,6 +4,7 @@ return [
'import' => 'Import',
'title' => 'Import :type',
- 'message' => 'Allowed file types: XLS, XLSX. Please, download the sample file.',
+ 'limitations' => 'Allowed file types: :extensions
Allowed max rows: :row_limit',
+ 'sample_file' => 'You can download the sample file and fill it with your data.',
];
diff --git a/resources/views/common/import/create.blade.php b/resources/views/common/import/create.blade.php
index c1b75a2a4..e95c20b83 100644
--- a/resources/views/common/import/create.blade.php
+++ b/resources/views/common/import/create.blade.php
@@ -8,9 +8,14 @@