<?php
/**
 * Created by PhpStorm.
 * User: 中闽 < 1464674022@qq.com >
 * Date: 2019/12/5
 * Time: 17:44
 */

namespace app\common\model;

use think\Model;

class Attachment extends Model
{
    // 关闭自动写入update_time字段
    protected $updateTime = false;

    const STATUS_OPEN = 1;
    const STATUS_WAIT = 0;
    const STATUS_CLOSE = -1;

    const STATUS = [
        self::STATUS_WAIT => '待审核',
        self::STATUS_OPEN => '已审核',
        self::STATUS_CLOSE => '已拒审'
    ];

    //status_text
    public function getStatusTextAttr($value, $data)
    {
        return self::STATUS[$data['status']]??'';
    }

    //audit_time
    public function getAuditTimeAttr($value, $data)
    {
        return $value ? date('Y-m-d H:i:s', $value) : '';
    }

    //关联管理员表
    public function admin()
    {
        return $this->belongsTo('Admin');
    }
}
