Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. [
  2. {
  3. "id": 1,
  4. "dhl_purchase_id": 1,
  5. "type": "import",
  6. "currency_id": 1,
  7. "total_amount": "1000.00",
  8. "payment_method_id": 2,
  9. "observations": null,
  10. "date": "2019-01-14 00:00:00",
  11. "created_at": "2019-01-14 17:24:29",
  12. "updated_at": "2019-01-16 13:12:45",
  13. "dhl_purchase": {
  14. "id": 1,
  15. "purchase_id": 4291,
  16. "purchase": {
  17. "id": 4291,
  18. "sale_id": 4820,
  19. "sale": {
  20. "id": 4820,
  21. "enterprise_id": 838,
  22. "enterprise": {
  23. "id": 838,
  24. "legal_name": "ENTERPRISE X"
  25. }
  26. }
  27. }
  28. },
  29. "currency": {
  30. "id": 1,
  31. "name": "$US"
  32. }
  33. },
  34. // ...
  35. ]
  36.  
  37. [
  38. {
  39. "id": 1,
  40. "type": "import",
  41. "total_amount": "1000.00",
  42. "date": "14/01/2019",
  43. "enterprise": {
  44. "id": 838,
  45. "legal_name": "ENTERPRISE X"
  46. }
  47. "currency": {
  48. "id": 1,
  49. "name": "$US"
  50. }
  51. },
  52. // ...
  53. ]
  54.  
  55. $dhl_payments->transform(function ($item, $key) use ($date_format) {
  56. return [
  57. 'key' => $key,
  58. 'id' => $item->id,
  59. 'type' => $item->type,
  60. 'date' => $item->date->format($date_format),
  61. 'total_amount' => $item->total_amount,
  62. 'currency' => $item->currency,
  63. 'enterprise' => $item->dhl_purchase->purchase->sale->enterprise, // El error da en esta línea!!!
  64. ];
  65. });
  66.  
  67. $dhl_payments->transform(function ($item, $key) use ($date_format) {
  68. return [
  69. 'key' => $key,
  70. 'id' => $item->id,
  71. 'type' => $item->type,
  72. 'date' => $item->date->format($date_format),
  73. 'total_amount' => $item->total_amount,
  74. 'currency' => $item->currency,
  75. 'enterprise' => $item->dhl_purchase
  76. ];
  77. });
  78.  
  79. [
  80. {
  81. "key": 0,
  82. "id": 1,
  83. "type": "import",
  84. "date": "14/01/2019",
  85. "total_amount": "1000.00",
  86. "currency": {
  87. "id": 1,
  88. "name": "$US"
  89. },
  90. "enterprise": null
  91. },
  92. {
  93. "key": 1,
  94. "id": 6,
  95. "type": "import",
  96. "date": "14/01/2019",
  97. "total_amount": "100.00",
  98. "currency": {
  99. "id": 1,
  100. "name": "$US"
  101. },
  102. "enterprise": null
  103. }
  104. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement