DocterInfo.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App\Imports\Docter;
  3. use App\Models\Docter;
  4. use App\Models\Organization;
  5. use App\Models\Qualification;
  6. use Maatwebsite\Excel\Concerns\ToModel;
  7. class DocterInfo 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. if (($row[0] == "姓名")) {
  17. return null;
  18. }
  19. // //职称
  20. // $qualification_id = 0;
  21. // if ($row[2])
  22. // {
  23. // $qualification_id = Qualification::firstOrCreate([
  24. // 'name' => $row[2]
  25. // ],[
  26. // 'name' => $row[2],
  27. // 'status' =>1
  28. // ]);
  29. // }
  30. if ($row[5] == null)
  31. {
  32. $avatar = '';
  33. }else
  34. {
  35. $avatar = $row[5];
  36. }
  37. return new Docter([
  38. //
  39. 'name' => $row[0],
  40. 'phone' => $row[1],
  41. // 'qualification_id' => $qualification_id,
  42. 'card_photo' => $row[3],
  43. 'practice' => $row[4],
  44. 'avatar' => $avatar,
  45. 'is_then' => 1,
  46. 'type' => 0
  47. ]);
  48. }
  49. }