<?php

namespace App\Imports\Docter;

use App\Models\Docter;
use App\Models\Organization;
use App\Models\Qualification;
use Maatwebsite\Excel\Concerns\ToModel;

class DocterInfo implements ToModel
{
    /**
    * @param array $row
    *
    * @return \Illuminate\Database\Eloquent\Model|null
    */
    public function model(array $row)
    {
        if (($row[0] == "姓名")) {
            return null;
        }
//        //职称
//        $qualification_id = 0;
//        if ($row[2])
//        {
//            $qualification_id = Qualification::firstOrCreate([
//                'name' => $row[2]
//            ],[
//                'name' => $row[2],
//                'status' =>1
//            ]);
//        }
        if ($row[5] == null)
        {
            $avatar = '';
        }else
        {
            $avatar = $row[5];
        }

        return new Docter([
            //
            'name' => $row[0],
            'phone' => $row[1],
//            'qualification_id' => $qualification_id,
            'card_photo' => $row[3],
            'practice' => $row[4],
            'avatar' => $avatar,
            'is_then' => 1,
            'type' => 1
        ]);
    }
}
