QueuedImportWithMiddleware.php 883 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 QueuedImportWithMiddleware 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. return new Group([
  19. 'name' => $row[0],
  20. ]);
  21. }
  22. public function middleware()
  23. {
  24. return [function () {
  25. throw new \Exception('Job reached middleware method');
  26. }];
  27. }
  28. /**
  29. * @return int
  30. */
  31. public function chunkSize(): int
  32. {
  33. return 100;
  34. }
  35. }