<?php

declare(strict_types=1);

namespace App\Model;



use Hyperf\Database\Model\Collection;
use Hyperf\Snowflake\Concern\Snowflake;

/**
 * @property int $hospital_id 主键id
 * @property string $hospital_name 医院名称
 * @property int $hospital_status 状态（0:禁用 1:正常 2:删除）
 * @property string $hospital_level_name 医院等级名称
 * @property string $post_code 邮政编码
 * @property string $tele_phone 电话
 * @property int $province_id 省份id
 * @property string $province 省份
 * @property int $city_id 城市id
 * @property string $city 城市
 * @property int $county_id 区县id
 * @property string $county 区县
 * @property string $address 地址
 * @property string $lat 纬度
 * @property string $lng 经度
 * @property string $desc 简介
 * @property \Carbon\Carbon $created_at 创建时间
 * @property \Carbon\Carbon $updated_at 修改时间
 */
class Hospital extends Model
{
    use Snowflake;

    /**
     * The table associated with the model.
     */
    protected ?string $table = 'hospital';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['hospital_id', 'hospital_name', 'hospital_status', 'hospital_level_name', 'post_code', 'tele_phone', 'province_id', 'province', 'city_id', 'city', 'county_id', 'county', 'address', 'lat', 'lng', 'desc', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['hospital_id' => 'string', 'hospital_status' => 'integer', 'province_id' => 'integer', 'city_id' => 'integer', 'county_id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    protected string $primaryKey = "hospital_id";

    /**
     * 获取信息-单条
     * @param array $params
     * @param array $fields
     * @return object|null
     */
    public static function getOne(array $params, array $fields = ['*']): object|null
    {
        return self::where($params)->first($fields);
    }

    /**
     * 获取数据-多
     * @param array $params
     * @param array $fields
     * @return Collection|array
     */
    public static function getList(array $params = [], array $fields = ['*']): Collection|array
    {
        return self::where($params)->get($fields);
    }

    /**
     * 新增医院-批量
     * @param array $data 新增数据
     * @return \Hyperf\Database\Model\Model|Hospital
     */
    public static function addHospital(array $data): \Hyperf\Database\Model\Model|Hospital
    {
        return self::create($data);
    }

}
