<?php

namespace app\common\model;

use think\Model;

class Activity extends Model
{
    // 设置字段信息
    protected $schema = [
        'id'          => 'int',
        'title'       => 'string',
        'main_image'  => 'string',
        'start_time'  => 'int',
        'address'     => 'string',
        'content'     => 'string',
        'create_time' => 'int',
        'join_num'    => 'int',
        'status'      => 'int',
        'priority'    => 'int',
    ];

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

    public function getStatusTextAttr($value, $data)
    {
        $status = [1 => '显示', 2 => '隐藏'];
        return $status[$data['status']];
    }
}