104 lines
2.6 KiB
PHP
104 lines
2.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Model;
|
|
|
|
|
|
|
|
use Hyperf\Database\Model\Collection;
|
|
use Hyperf\Database\Model\Relations\HasOne;
|
|
use Hyperf\Snowflake\Concern\Snowflake;
|
|
|
|
/**
|
|
* @property int $doctor_expertise_id 主键id
|
|
* @property int $doctor_id 医生id
|
|
* @property int $expertise_id 专长id
|
|
* @property \Carbon\Carbon $created_at 创建时间
|
|
* @property \Carbon\Carbon $updated_at 修改时间
|
|
*/
|
|
class DoctorExpertise extends Model
|
|
{
|
|
use Snowflake;
|
|
|
|
/**
|
|
* The table associated with the model.
|
|
*/
|
|
protected ?string $table = 'doctor_expertise';
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*/
|
|
protected array $fillable = ['doctor_expertise_id', 'doctor_id', 'expertise_id', 'created_at', 'updated_at'];
|
|
|
|
/**
|
|
* The attributes that should be cast to native types.
|
|
*/
|
|
protected array $casts = ['doctor_expertise_id' => 'integer', 'doctor_id' => 'integer', 'expertise_id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
|
|
|
|
protected string $primaryKey = "doctor_expertise_id";
|
|
|
|
/**
|
|
* 关联专长表
|
|
*/
|
|
public function DiseaseClassExpertise(): HasOne
|
|
{
|
|
return $this->hasOne(DiseaseClassExpertise::class, 'expertise_id', 'expertise_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 $params
|
|
* @param array $fields
|
|
* @return Collection|array
|
|
*/
|
|
public static function getDiseaseClassExpertiseList(array $params, array $fields = ['*']): Collection|array
|
|
{
|
|
return self::with(['DiseaseClassExpertise'])->where($params)->get($fields);
|
|
}
|
|
|
|
/**
|
|
* 删除
|
|
* @param array $params
|
|
* @return int|mixed
|
|
*/
|
|
public static function deleteDoctorExpertise(array $params): mixed
|
|
{
|
|
return self::where($params)->delete();
|
|
}
|
|
|
|
/**
|
|
* 新增
|
|
* @param array $data
|
|
* @return DoctorExpertise|\Hyperf\Database\Model\Model
|
|
*/
|
|
public static function addDoctorExpertise(array $data): DoctorExpertise|\Hyperf\Database\Model\Model
|
|
{
|
|
return self::create($data);
|
|
}
|
|
}
|