belongsTo('App\Owner','owner_id','id'); } public function carrier(){ return $this->belongsTo('App\Carrier','carrier_id','id'); } public function origination_city(){ return $this->belongsTo('App\City','origination_city_id','id'); } public function destination_city(){ return $this->belongsTo('App\City','destination_city_id','id'); } public function wmsCommodities(){ return $this->hasMany('App\WMSWaybillOrder','OrderNo','wms_bill_number'); } public function warehouse_weight_unit(){ return $this->belongsTo('App\Unit','warehouse_weight_unit_id','id'); } public function carrier_weight_unit(){ return $this->belongsTo('App\Unit','carrier_weight_unit_id','id'); } public function warehouse_weight_unit_other(){ return $this->belongsTo('App\Unit','warehouse_weight_unit_id_other','id'); } public function carrier_weight_unit_other(){ return $this->belongsTo('App\Unit','carrier_weight_unit_id_other','id'); } public function carType(){ return $this->belongsTo('App\CarType','carType_id','id'); } public function waybillAuditLogs(){ return $this->hasMany('App\WaybillAuditLog','waybill_id','id'); } public function uploadFile(){ return $this->hasOne('App\UploadFile','table_id','id')->where('table_name','waybills'); } public function waybill_on_top(){ return $this->belongsTo('App\WaybillOnTop','waybill_id','id'); } public function amount_unit(){ return $this->belongsTo('App\Unit','amount_unit_id','id'); } static public function setWeightByOrderCode($orderCode,$weight){ if(empty($orderCode))return; $waybill=Waybill::where('wms_bill_number',$orderCode)->where('status','!=','已完结') ->where('status','!=','无模型')->first(); if ($waybill){ $waybill->warehouse_weight_other=$weight; $waybill->warehouse_weight_unit_id_other=1; $waybill->update(); } } public function getUploadFileUrlAttribute(){ return $this['uploadFile']? asset('/storage'.$this['uploadFile']['url']):null; } public function getUploadFileTypeAttribute(){ return $this['uploadFile']? $this['uploadFile']['type']:null; } public function getOwnerNameAttribute(){ return $this['owner']? $this['owner']['name']:null; } public function getCarrierNameAttribute(){ return $this['carrier']? $this['carrier']['name']:null; } public function getOriginationCityNameAttribute(){ return $this['origination_city']? $this['origination_city']['name']:null; } public function getDestinationCityNameAttribute(){ return $this['destination_city']? $this['destination_city']['name']:null; } function getDestinationProvinceNameAttribute(){ return $this['destination_city'] ? $this['destination_city']['province_name']:null; } public function getWarehouseWeightUnitNameAttribute(){ return $this['warehouse_weight_unit']? $this['warehouse_weight_unit']['name']:null; } public function getCarrierWeightUnitNameAttribute(){ return $this['carrier_weight_unit']? $this['carrier_weight_unit']['name']:null; } public function getWarehouseWeightUnitOtherNameAttribute(){ return $this['warehouse_weight_unit_other']? $this['warehouse_weight_unit_other']['name']:null; } public function getCarrierWeightUnitOtherNameAttribute(){ return $this['carrier_weight_unit_other']? $this['carrier_weight_unit_other']['name']:null; } public function getAmountUnitNameAttribute(){ return $this['amount_unit']? $this['amount_unit']['name']:null; } }