QueuedImportWithFailure.php 793 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace Maatwebsite\Excel\Tests\Data\Stubs;
  3. use Illuminate\Contracts\Queue\ShouldQueue;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Maatwebsite\Excel\Concerns\Importable;
  6. use Maatwebsite\Excel\Concerns\ToModel;
  7. use Maatwebsite\Excel\Concerns\WithChunkReading;
  8. use Maatwebsite\Excel\Tests\Data\Stubs\Database\Group;
  9. class QueuedImportWithFailure implements ShouldQueue, ToModel, WithChunkReading
  10. {
  11. use Importable;
  12. /**
  13. * @param array $row
  14. * @return Model|null
  15. */
  16. public function model(array $row)
  17. {
  18. throw new \Exception('Something went wrong in the chunk');
  19. return new Group([
  20. 'name' => $row[0],
  21. ]);
  22. }
  23. /**
  24. * @return int
  25. */
  26. public function chunkSize(): int
  27. {
  28. return 100;
  29. }
  30. }