Ronda.php 998 字节
<?php

namespace app\admin\model;

use think\Model;


class Ronda extends Model
{

    

    

    // 表名
    protected $name = 'ronda';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'holdtime_text'
    ];
    

    



    public function getHoldtimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['holdtime']) ? $data['holdtime'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }

    protected function setHoldtimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }


    public function campus()
    {
        return $this->belongsTo('Campus', 'campus_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}