<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class OwnerOutStorageRule extends Model
{
    protected $fillable = [
        "owner_price_operation_id",         //作业计费ID
        "strategy",                         //出库策略
        "amount",                           //起步数
        "unit_id",                          //单位ID
        "unit_price",                       //单价
        "feature",                          //特征
        "priority",                         //优先级 值越大越高
    ];
    public $timestamps=false;

    public static $features = null;
    public static $columnMapping = null;

    public function unit()
    {   //单位
        return $this->hasOne(Unit::class,"id","unit_id");
    }


    /* 格式化依据静态参数，在调用前设置  */
    public function getFeatureFormatAttribute()
    {
        if ($this->strategy == '默认')return "/";
        return app("FeatureService")->formatFeature(self::$features,$this->feature,self::$columnMapping);
    }
}
