<?php

namespace app\common\model;

use think\Model;

class ResumeInvite extends Model
{
    // 设置字段信息
    protected $schema = [
        'id'         => 'int',
        'workerid'   => 'int',
        'userid'     => 'int',
        'status'     => 'tinyint',
        'remark'     => 'string',
        'createtime' => 'int',
    ];

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

    public function getStatusTextAttr($value, $data)
    {
        $status = [1 => '邀请中', 2 => '邀请成功', 3 => '拒绝邀请'];
        return $status[$data['status']];
    }

    public function worker()
    {
        return $this->hasOne(Worker::class, 'id', 'workerid');
    }

    public function user()
    {
        return $this->hasOne(User::class, 'id', 'userid');
    }
}