ImportWithEventsChunksAndBatches.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Maatwebsite\Excel\Tests\Data\Stubs;
  3. use Maatwebsite\Excel\Concerns\ToModel;
  4. use Maatwebsite\Excel\Concerns\WithBatchInserts;
  5. use Maatwebsite\Excel\Concerns\WithChunkReading;
  6. use Maatwebsite\Excel\Events\AfterBatch;
  7. use Maatwebsite\Excel\Events\AfterChunk;
  8. class ImportWithEventsChunksAndBatches extends ImportWithEvents implements WithBatchInserts, ToModel, WithChunkReading
  9. {
  10. /**
  11. * @var callable
  12. */
  13. public $afterBatch;
  14. /**
  15. * @var callable
  16. */
  17. public $afterChunk;
  18. /**
  19. * @return array
  20. */
  21. public function registerEvents(): array
  22. {
  23. return parent::registerEvents() + [
  24. AfterBatch::class => $this->afterBatch ?? function () {
  25. },
  26. AfterChunk::class => $this->afterChunk ?? function () {
  27. },
  28. ];
  29. }
  30. public function model(array $row)
  31. {
  32. }
  33. public function batchSize(): int
  34. {
  35. return 100;
  36. }
  37. public function chunkSize(): int
  38. {
  39. return 500;
  40. }
  41. }