<?php

namespace app\admin\model;

use think\Model;

/**
 * ReqInvoiceApply
 */
class ReqInvoiceApply extends Model
{
    // 表名
    protected $name = 'req_invoice_apply';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = true;

    protected static function onBeforeInsert($model)
    {
        $pk         = $model->getPk();
        $model->$pk = \app\common\library\SnowFlake::generateParticle();
    }

    public function getIdAttr($value): string
    {
        return (string)$value;
    }

    public function getInvoiceAmountAttr($value): float
    {
        return (float)$value;
    }

    public function reqOrder()
    {
        return $this->belongsTo(\app\admin\model\ReqOrder::class, 'req_id', 'id');
    }
}