<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

use App\Traits\ModelLogChanging;

class OwnerStoragePriceModel extends Model
{
    use ModelLogChanging;

    protected $fillable = [
        "name",             //名称
        "counting_type",    //计费类型
        "using_type",       //用仓类型
        "minimum_area",     //最低起租面积
        "price",            //单价
        "discount_type",    //减免类型
        "discount_value",   //减免值
        "unit_id",          //单位ID
        "time_unit_id",     //计时单位ID
        "operation",        //操作
        "target_id",        //目标ID
        "amount_interval",  //数量区间
        "tax_rate_id",      //税率
    ];
    protected $casts = [
        "amount_interval" => "array",
        "price" => "array"
    ];

    public function unit()
    {   //单位
        return $this->belongsTo(Unit::class);
    }
    public function owners()
    {   //货主
        return $this->belongsToMany(Owner::class,"owner_storage_price_model_owner","owner_storage_price_model_id","owner_id");
    }
    public function timeUnit()
    {   //计时单位
        return $this->belongsTo(Unit::class,"time_unit_id");
    }
    public function taxRate()
    {   //税率
        return $this->belongsTo(TaxRate::class);
    }
}
