ImportMember.php 736 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Imports\Vaccines;
  3. use App\Models\Vaccines;
  4. use Maatwebsite\Excel\Concerns\ToModel;
  5. use Maatwebsite\Excel\Concerns\WithStartRow;
  6. use Maatwebsite\Excel\Facades\Excel;
  7. class ImportMember implements ToModel
  8. {
  9. /**
  10. * @param array $row
  11. *
  12. * @return \Illuminate\Database\Eloquent\Model|null
  13. */
  14. public function model(array $row)
  15. {
  16. return new Vaccines([
  17. //
  18. 'type' => $row[1],
  19. 'name' => $row[2],
  20. 'introduction' => $row[3],
  21. 'price' => $row[4],
  22. 'remark' => $row[5],
  23. 'supplier' => $row[6],
  24. 'states' => $row[7]
  25. ]);
  26. }
  27. public function startRow(): int
  28. {
  29. return 2;
  30. }
  31. }