Skip to content

Add WithCustomStartCell when import #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/ModelRecordImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -101,4 +102,9 @@ public function sheets(): array
public function onUnknownSheet($sheetName): void
{
}

public function startCell(): string
{
return ModelUpload::importStartCell();
}
}
12 changes: 12 additions & 0 deletions src/ModelUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down