<?php

namespace App;

use App\Services\ProcessMethodService;
use Illuminate\Database\Eloquent\Model;

use App\Traits\ModelLogChanging;

class OwnerFeeDetail extends Model
{
//    use ModelLogChanging;

    protected $fillable = [
        "owner_id",         //货主ID
        "worked_at",        //作业时间
        "type",             //类型
        "shop_id",          //店铺ID
        "operation_bill",   //发/收/退/提货单号
        "consignee_name",   //收件人
        "consignee_phone",  //收件人电话
        "commodity_amount", //商品数量
        "logistic_bill",    //快递单号
        "volume",           //体积
        "weight",           //重量
        "logistic_id",      //物流ID
        "process_method_id",//加工类型ID
        "work_fee",         //作业费
        "logistic_fee",     //物流费
        "created_at",       //创建时间
        "outer_id",         //关联表ID
        "outer_table_name", //关联表名
        "work_tax_fee",     //作业税费
        "logistic_tax_fee", //物流税费
        "province",         //省份
    ];
    public $timestamps = false;

    public function owner()
    {   //货主
        return $this->hasOne(Owner::class,"id","owner_id");
    }
    public function shop()
    {   //店铺
        return $this->hasOne(Shop::class,"id","shop_id");
    }
    public function logistic()
    {   //物流
        return $this->hasOne(Logistic::class,"id","logistic_id");
    }
    public function processMethod()
    {   //作业类型
        return $this->hasOne(ProcessMethod::class,"id","process_method_id");
    }
    public function order()
    {   //出库单
        return $this->belongsTo(Order::class,"outer_id","id");
    }
    public function items()
    {   //快递费子项
        return $this->hasMany(OwnerFeeDetailLogistic::class,"owner_fee_detail_id","id");
    }
}
