From 0f6952ee1725c585e8a9b9c9900e7fea5af0ac46 Mon Sep 17 00:00:00 2001 From: Nuradiyana Date: Tue, 16 Jan 2024 15:46:09 +0700 Subject: [PATCH] Add `WithCustomStartCell` when import --- src/ModelRecordImport.php | 8 +++++++- src/ModelUpload.php | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/ModelRecordImport.php b/src/ModelRecordImport.php index 93a5639..c9a3f08 100644 --- a/src/ModelRecordImport.php +++ b/src/ModelRecordImport.php @@ -19,9 +19,10 @@ use FromHome\ModelUpload\Models\ModelUploadRecord; use Maatwebsite\Excel\Concerns\SkipsUnknownSheets; use Maatwebsite\Excel\Concerns\WithMultipleSheets; +use Maatwebsite\Excel\Concerns\WithCustomStartCell; use FromHome\ModelUpload\Jobs\ProcessModelRecordJob; -final class ModelRecordImport implements ShouldQueue, SkipsUnknownSheets, ToModel, WithBatchInserts, WithChunkReading, WithEvents, WithHeadingRow, WithMultipleSheets +final class ModelRecordImport implements ShouldQueue, SkipsUnknownSheets, ToModel, WithBatchInserts, WithChunkReading, WithCustomStartCell, WithEvents, WithHeadingRow, WithMultipleSheets { use Importable; @@ -101,4 +102,9 @@ public function sheets(): array public function onUnknownSheet($sheetName): void { } + + public function startCell(): string + { + return ModelUpload::importStartCell(); + } } diff --git a/src/ModelUpload.php b/src/ModelUpload.php index 4eb57f8..7952ee6 100755 --- a/src/ModelUpload.php +++ b/src/ModelUpload.php @@ -12,6 +12,18 @@ final class ModelUpload { + private static string $importStartCell = 'A1'; + + public static function importStartCell(): string + { + return self::$importStartCell; + } + + public static function useImportStartCell(string $importStartCell): void + { + self::$importStartCell = $importStartCell; + } + public static function registerRecordProcessors(array $processors): void { /** @var RecordProcessorManager $manager */