You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.1 KiB
33 lines
1.1 KiB
<?php
|
|
|
|
namespace App\Http\Ingestion\Excel\Identity;
|
|
|
|
use App\Domains\Identity\Integration\Mappers\UserDataMapper;
|
|
use App\Domains\Identity\Models\User;
|
|
use App\Domains\System\Actions\Integration\RunGenericImportPipeline;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Support\Collection;
|
|
use Maatwebsite\Excel\Concerns\ToCollection;
|
|
use Maatwebsite\Excel\Concerns\WithChunkReading;
|
|
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
|
|
class UserImport implements ShouldQueue, ToCollection, WithChunkReading, WithHeadingRow
|
|
{
|
|
/**
|
|
* @param Collection $rows A chunk of rows defined by chunkSize()
|
|
*/
|
|
public function collection(Collection $rows): void
|
|
{
|
|
// Excel specific processor reads a file chunk, then uses the generic integration pipeline
|
|
app(RunGenericImportPipeline::class)->execute(
|
|
rows: $rows,
|
|
mapper: app(UserDataMapper::class),
|
|
modelClass: User::class,
|
|
);
|
|
}
|
|
|
|
public function chunkSize(): int
|
|
{
|
|
return 200; // Optimal balance for shared hosting memory limits
|
|
}
|
|
}
|
|
|