<?php

namespace app\common\model;

use think\Model;

class Coach extends Model
{
    // 设置字段信息
    protected $schema = [
        'id'         => 'int',
        'agentid'    => 'int',
        'title'      => 'string',
        'content'    => 'string',
        'num'        => 'int',
        'status'     => 'tinyint',
        'coachtime'  => 'date',
        'createtime' => 'int',
    ];

    // 设置字段自动转换类型
    protected $type = [
        'createtime' => 'timestamp:Y-m-d H:i',
    ];
    public static $status = [1 => '待审核', 2 => '优秀', 3 => '合格', 4 => '不合格'];

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

    public function agent()
    {
        return $this->hasOne(Agent::class, 'id', 'agentid');
    }
}