| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 | <?phpnamespace app\admin\model;use think\Model;use think\Db;class Useridconfirm extends Model{            // 表名    protected $name = 'user_idconfirm';        // 自动写入时间戳字段    protected $autoWriteTimestamp = 'int';    // 定义时间戳字段名    protected $createTime = 'createtime';    protected $updateTime = 'updatetime';    protected $deleteTime = false;    // 追加属性    protected $append = [        'status_text'    ];        protected static function init()    {        self::beforeDelete(function ($row){                $update = [                    'idcard_status'=> '-1',                ];                Db::name('user')->where('id',$row['user_id'])->update($update);        });    }    public function getStatusList()    {        return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2')];    }    public function getStatusTextAttr($value, $data)    {        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');        $list = $this->getStatusList();        return isset($list[$value]) ? $list[$value] : '';    }    public function user()    {        return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);    }}
 |