Treasured.php 1.4 KB
<?php

namespace app\admin\model;

use think\Model;
use traits\model\SoftDelete;

class Treasured extends Model
{

    use SoftDelete;

    

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

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

    // 追加属性
    protected $append = [
        'status_text',
        'is_audit_text'
    ];


    public function getQrCodeAttr($value,$data)
    {
        return this_url().$value;
    }


    
    public function getStatusList()
    {
        return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2')];
    }

    public function getIsAuditList()
    {
        return ['0' => __('Is_audit 0'), '1' => __('Is_audit 1'), '2' => __('Is_audit 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 getIsAuditTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_audit']) ? $data['is_audit'] : '');
        $list = $this->getIsAuditList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}