123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class Maintainbaojia extends Model
- {
-
-
- // 表名
- protected $table = 'maintain_baojia';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'integer';
- // 定义时间戳字段名
- protected $createTime = false;
- protected $updateTime = 'updatetime';
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'baojia_time_text',
- 'status_text',
- 'baojia_audit_time_text',
- 'baojia_useraudit_time_text'
- ];
-
-
- public function getStatusList()
- {
- return ['20' => __('Status 20'), '22' => __('Status 22'), '30' => __('Status 30'), '40' => __('Status 40')];
- }
- public function getBaojiaTimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['baojia_time']) ? $data['baojia_time'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
- $list = $this->getStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getBaojiaAuditTimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['baojia_audit_time']) ? $data['baojia_audit_time'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getBaojiaUserauditTimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['baojia_useraudit_time']) ? $data['baojia_useraudit_time'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- protected function setBaojiaTimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- protected function setBaojiaAuditTimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- protected function setBaojiaUserauditTimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- public function maintain()
- {
- return $this->belongsTo('Maintain', 'order_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function company()
- {
- return $this->belongsTo('Company', 'company_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function user()
- {
- return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function admina()
- {
- return $this->belongsTo('app\admin\model\pc\Admin', 'baojia_staffid', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function adminb()
- {
- return $this->belongsTo('app\admin\model\pc\Admin', 'baojia_audit_staffid', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- }
|