<?php

namespace app\common\model;

use think\Model;

class Feedback extends Model
{
    // 设置字段信息
    protected $schema = [
        'id'         => 'int',
        'userid'     => 'int',
        'name'       => 'string',
        'mobile'     => 'string',
        'content'    => 'string',
        'status'     => 'int',
        'createtime' => 'int',
    ];

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

    // 关联FormItem
    public function User()
    {
        return $this->hasMany(User::class, "id", "userid");
    }

    public function getStatusTextAttr($value, $data)
    {
        $status = [1 => '已处理', 2 => '待处理'];
        return $status[$data['status']];
    }
}