<?php

namespace app\admin\model;

use support\Db;
use support\Model;

/**
 * 医疗服务-医生每天预约数量设置
 * Class MedicalCareSubject
 * @package app\admin\model
 */
class MedicalCareDoctorAppointment extends Model
{

    const DEL_NO  = 0;
    const DEL_YES = 1;
    const APPOINTMENT_DEL = [
        self::DEL_NO  => '未删除',
        self::DEL_YES => '已删除'
    ];

    const WORK_MONDAY    = '一';
    const WORK_TUESDAY   = '二';
    const WORK_WEDNESDAY = '三';
    const WORK_THURSDAY  = '四';
    const WORK_FRIDAY    = '五';
    const WORK_SATURDAY  = '六';
    const WORK_SUNDAY    = '日';
    const WORK_TIME = [
        self::WORK_MONDAY    => 'appointment_monday',
        self::WORK_TUESDAY   => 'appointment_tuesday',
        self::WORK_WEDNESDAY => 'appointment_wednesday',
        self::WORK_THURSDAY  => 'appointment_thursday',
        self::WORK_FRIDAY    => 'appointment_friday',
        self::WORK_SATURDAY  => 'appointment_saturday',
        self::WORK_SUNDAY    => 'appointment_sunday'
    ];
    const WORK_TIME_ARR = ['一', '二', '三', '四', '五', '六', '日'];
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'medical_care_doctor_appointment';

    public $timestamps = false;

    /**
     * Notes:获取医生设置详情
     * @param int $doctor_id
     * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|null
     * User: yym
     * Date: 2022/9/27
     */
    public static function getDoctorAppointment(int $doctor_id)
    {
        return static::where(['appointment_doctor_id' => $doctor_id, 'appointment_del' => static::DEL_NO])->first();
    }

    /**
     * Notes:插入数据
     * @param array $data
     * @return int
     * User: yym
     * Date: 2022/9/27
     */
    public static function insertData(array $data)
    {
        return static::insertGetId($data);
    }

    /**
     * Notes:更新数据
     * @param int $doctor_id
     * @param array $data
     * @return int
     * User: yym
     * Date: 2022/9/27
     */
    public static function updateData(int $doctor_id, array $data)
    {
        return static::where(['appointment_doctor_id' => $doctor_id])->update($data);
    }
}
