Waybill.php 3.5 KB

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