Waybill.php 3.3 KB

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