<?php

namespace app\common\model;

use think\Model;

class DemandSnatch extends Model
{
    // 设置字段信息
    protected $schema = [
        'id'         => 'int',
        'demand_id'  => 'int',
        'worker_id'  => 'int',
        'num'        => 'int',
        'status'     => 'int',
        'createtime' => 'int',
    ];

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

    public function demand()
    {
        return $this->hasOne(Demand::class, 'id', 'demand_id');
    }

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

    public function getStatusTextAttr($value,$data)
    {
        $fstatus = [1=>'待审核', 2=>'审核通过', 3=>'已完成'];
        return $fstatus[$data['status']];
    }
}