智慧教务系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

69 lines
1.4 KiB

<?php
namespace app\model\document;
use core\base\BaseModel;
use think\model\relation\HasOne;
use app\model\contract\Contract;
/**
* 文档数据源配置模型
*/
class DocumentDataSourceConfig extends BaseModel
{
protected $pk = 'id';
protected $name = 'document_data_source_config';
/**
* 关联合同表
*/
public function contract(): HasOne
{
return $this->hasOne(Contract::class, 'id', 'contract_id');
}
/**
* 搜索器:合同ID
*/
public function searchContractIdAttr($query, $value, $data)
{
if ($value) {
$query->where("contract_id", $value);
}
}
/**
* 搜索器:占位符
*/
public function searchPlaceholderAttr($query, $value, $data)
{
if ($value) {
$query->where("placeholder", 'like', '%' . $value . '%');
}
}
/**
* 字段类型获取器
* @param $value
* @return string
*/
public function getFieldTypeTextAttr($value)
{
$typeMap = [
'text' => '文本',
'number' => '数字',
'date' => '日期',
'datetime' => '日期时间'
];
return $typeMap[$this->getAttr('field_type')] ?? '文本';
}
/**
* 状态获取器
* @param $value
* @return string
*/
public function getIsActiveTextAttr($value)
{
return $this->getAttr('is_active') ? '启用' : '禁用';
}
}