added limit to import
This commit is contained in:
parent
c78519cc2e
commit
cbf2314dec
@ -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)
|
||||
|
@ -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'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -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' => [
|
||||
|
@ -4,6 +4,7 @@ return [
|
||||
|
||||
'import' => 'Import',
|
||||
'title' => 'Import :type',
|
||||
'message' => 'Allowed file types: XLS, XLSX. Please, <a target="_blank" href=":link"><strong>download</strong></a> the sample file.',
|
||||
'limitations' => 'Allowed file types: :extensions<br>Allowed max rows: :row_limit',
|
||||
'sample_file' => 'You can <a target="_blank" href=":download_link"><strong>download</strong></a> the sample file and fill it with your data.',
|
||||
|
||||
];
|
||||
|
@ -8,9 +8,14 @@
|
||||
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert-warning alert-important">
|
||||
{!! trans('import.limitations', ['extensions' => strtoupper(config('excel.imports.extensions')), 'row_limit' => config('excel.imports.row_limit')]) !!}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert-info alert-important">
|
||||
{!! trans('import.message', ['link' => $sample_file]) !!}
|
||||
{!! trans('import.sample_file', ['download_link' => $sample_file]) !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user