Waybill.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use App\Traits\ModelTimeFormat;
  5. use Illuminate\Database\Eloquent\SoftDeletes;
  6. class Waybill extends Model
  7. {
  8. use ModelTimeFormat;
  9. use SoftDeletes;
  10. protected $fillable=[
  11. 'status','type','waybill_number','owner_id','wms_bill_number','origination','destination','recipient','recipient_mobile','charge','ordering_remark',
  12. 'carrier_id','carrier_bill','origination_city_id','destination_city_id','warehouse_weight','warehouse_weight_unit_id','carrier_weight','carrier_weight_unit_id','carType_id',
  13. 'car_owner_info','fee','pick_up_fee','other_fee','collect_fee','dispatch_remark','waybill_price_model_id','warehouse_weight_other','warehouse_weight_unit_id_other'
  14. ,'carrier_weight_other','carrier_weight_unit_id_other','source_bill','mileage','amount','inquire_tel',
  15. ];
  16. protected $appends=[
  17. 'origination_city_name',
  18. 'carrier_name',
  19. 'owner_name',
  20. 'destination_city_name',
  21. 'warehouse_weight_unit_name',
  22. 'carrier_weight_unit_name',
  23. 'warehouse_weight_unit_other_name',
  24. 'carrier_weight_unit_other_name',
  25. 'waybillOnTop','remake',
  26. ];
  27. public function owner(){
  28. return $this->belongsTo('App\Owner','owner_id','id');
  29. }
  30. public function carrier(){
  31. return $this->belongsTo('App\Carrier','carrier_id','id');
  32. }
  33. public function origination_city(){
  34. return $this->belongsTo('App\City','origination_city_id','id');
  35. }
  36. public function destination_city(){
  37. return $this->belongsTo('App\City','destination_city_id','id');
  38. }
  39. public function wmsCommodities(){
  40. return $this->hasMany('App\WMSWaybillOrder','OrderNo','wms_bill_number');
  41. }
  42. public function warehouse_weight_unit(){
  43. return $this->belongsTo('App\Unit','warehouse_weight_unit_id','id');
  44. }
  45. public function carrier_weight_unit(){
  46. return $this->belongsTo('App\Unit','carrier_weight_unit_id','id');
  47. }
  48. public function warehouse_weight_unit_other(){
  49. return $this->belongsTo('App\Unit','warehouse_weight_unit_id_other','id');
  50. }
  51. public function carrier_weight_unit_other(){
  52. return $this->belongsTo('App\Unit','carrier_weight_unit_id_other','id');
  53. }
  54. public function carType(){
  55. return $this->belongsTo('App\CarType','carType_id','id');
  56. }
  57. public function waybillAuditLogs(){
  58. return $this->hasMany('App\WaybillAuditLog','waybill_id','id');
  59. }
  60. public function waybillOnTop(){
  61. return $this->hasOne('App\WaybillOnTop','id','id');
  62. }
  63. public function getOwnerNameAttribute(){
  64. return $this['owner']? $this['owner']['name']:null;
  65. }
  66. public function getCarrierNameAttribute(){
  67. return $this['carrier']? $this['carrier']['name']:null;
  68. }
  69. public function getOriginationCityNameAttribute(){
  70. return $this['origination_city']? $this['origination_city']['name']:null;
  71. }
  72. public function getDestinationCityNameAttribute(){
  73. return $this['destination_city']? $this['destination_city']['name']:null;
  74. }
  75. public function getWarehouseWeightUnitNameAttribute(){
  76. return $this['warehouse_weight_unit']? $this['warehouse_weight_unit']['name']:null;
  77. }
  78. public function getCarrierWeightUnitNameAttribute(){
  79. return $this['carrier_weight_unit']? $this['carrier_weight_unit']['name']:null;
  80. }
  81. public function getWarehouseWeightUnitOtherNameAttribute(){
  82. return $this['warehouse_weight_unit_other']? $this['warehouse_weight_unit_other']['name']:null;
  83. }
  84. public function getCarrierWeightUnitOtherNameAttribute(){
  85. return $this['carrier_weight_unit_other']? $this['carrier_weight_unit_other']['name']:null;
  86. }
  87. }