<?php

namespace app\common\model;

class VoteModel extends BaseModel
{
    // 设置表名
    protected $name = 'vote';

    //自动完成
    protected $autoWriteTimestamp = true;

    // 设置字段自动转换类型
    protected $type = [
        'start_time' => 'timestamp:Y-m-d H:i:s',
        'end_time'   => 'timestamp:Y-m-d H:i:s',
        'option'     => 'array',
    ];

    // 常量
    const STATUS = [1 => '显示', 2 => '隐藏'];

    const STATUS_SHOW = 1;
    const STATUS_HIDE = 2;

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