Files
code-bang/backend/application/common/model/demand/Contracts.php
T
2026-09-17 16:25:31 +08:00

68 lines
1.5 KiB
PHP

<?php
namespace app\common\model\demand;
use think\Model;
class Contracts extends Model
{
// 表名
protected $name = 'demand_contracts';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = false;
// 追加属性
protected $append = [
'status_text',
'signed_time_text'
];
protected $type = [
'data_json' => 'json',
];
public function getStatusList()
{
return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3')];
}
public function getStatusTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
$list = $this->getStatusList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getSignedTimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['signed_time']) ? $data['signed_time'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
protected function setSignedTimeAttr($value)
{
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
}
public function demandBidding()
{
return $this->hasOne('app\common\model\demand\Biddings', 'id', 'bidding_id');
}
}