OrderTracking.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace App;
  3. use App\Traits\ModelTimeFormat;
  4. use Illuminate\Database\Eloquent\Model;
  5. use App\Traits\LogModelChanging;
  6. class OrderTracking extends Model
  7. {
  8. use LogModelChanging;
  9. use ModelTimeFormat;
  10. protected $fillable = [
  11. 'order_package_commodity_id','owner_id','logistic_id',
  12. 'web_order_number',
  13. 'pick_up_at','sale','client','order_client_code',
  14. 'order_remark','pallet_total','planning_sent_at',
  15. 'is_on_duty_shift','is_arrival','signed_at',
  16. 'receive_bill_status','remark','gross_weight','bulk'];
  17. /*
  18. * order_package_commodity_id 订单商品id
  19. * owner_id 货主
  20. * web_order_number WEB+订单号
  21. * pick_up_at 提货时间
  22. * sale 销售
  23. * client 客户
  24. * order_client_code 订单号
  25. * order_remark 订单备注
  26. * pallet_total 托盘合计
  27. * planning_sent_at 应送达时间
  28. * is_on_duty_shift 是否赶上卡班
  29. * is_arrival 到货情况
  30. * signed_at 签收时间
  31. * receive_bill_status
  32. * remark 签收单情况
  33. * gross_weight 重量
  34. * bulk 体积
  35. */
  36. protected $appends =[
  37. 'ownerName','sku','packageWeight','packageBulk','orderCity','packageLogisticNumber','packageLogistic','orderClientNumber'
  38. ];
  39. public function commodities(){
  40. return $this->hasOne(OrderPackageCommodities::class,'id','order_package_commodity_id');
  41. }
  42. public function owner(){
  43. return $this->hasOne(Owner::class,'id','owner_id');
  44. }
  45. public function logistic(){
  46. return $this->hasOne(Logistic::class,'id','logistic_id');
  47. }
  48. public function uploadFile()
  49. {
  50. return $this->hasOne(UploadFile::class,'table_id','order_client_code')->where('table_name','order_trackings');
  51. }
  52. public function getOwnerNameAttribute(){
  53. return $this->owner['name'] ?? '';
  54. }
  55. public function getSkuAttribute(){
  56. return ['sku' => $this->commodities['commodity']['sku'] ?? '',
  57. 'skuName' => $this->commodities['commodity']['name'] ?? '',
  58. 'skuAmount' => $this->commodities['amount'] ?? ''];
  59. }
  60. public function getPackageWeightAttribute(){
  61. return $this->commodities->package['weight'] ?? '';
  62. }
  63. public function getPackageBulkAttribute(){
  64. return $this->commodities->package['bulk'] ?? '';
  65. }
  66. public function getOrderCityAttribute(){
  67. return $this->commodities->package->order['city'] ?? '';
  68. }
  69. public function getPackageLogisticNumberAttribute(){
  70. return $this->commodities->package['logistic_number'] ?? '';
  71. }
  72. public function getPackageLogisticAttribute(){
  73. return $this->commodities->package->order->logistic['name'] ?? '';
  74. }
  75. public function getOrderClientNumberAttribute(){
  76. return $this->commodities->package->order['client_code'] ?? '';
  77. }
  78. }