PaymentTransferResource.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace App\Http\Resources;
  3. use App\Models\PaymentTransfer;
  4. use Illuminate\Http\Request;
  5. use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
  6. use Illuminate\Http\Resources\Json\JsonResource;
  7. class PaymentTransferResource extends JsonResource
  8. {
  9. /**
  10. * Transform the resource into an array.
  11. *
  12. * @return array<string, mixed>
  13. */
  14. public function toArray(Request $request): array
  15. {
  16. return [
  17. 'id' => $this->id,
  18. 'payment_id' => $this->payment_id,
  19. 'provider_id' => $this->provider_id,
  20. 'gateway_provider' => $this->gateway_provider,
  21. 'gateway_entity_reference' => $this->gateway_entity_reference,
  22. 'gateway_entity_label' => $this->gateway_entity_label,
  23. 'gateway_operation_reference' => $this->gateway_operation_reference,
  24. 'gateway_operation_label' => $this->gateway_operation_label,
  25. 'gateway_parent_reference' => $this->gateway_parent_reference,
  26. 'gateway_parent_label' => $this->gateway_parent_label,
  27. 'gateway_transfer_target_reference' => $this->gateway_transfer_target_reference,
  28. 'gateway_transfer_target_label' => $this->gateway_transfer_target_label,
  29. 'status' => $this->status,
  30. 'gross_amount' => $this->gross_amount,
  31. 'gateway_fee_amount' => $this->gateway_fee_amount,
  32. 'net_amount' => $this->net_amount,
  33. 'transferred_at' => $this->transferred_at?->toISOString(),
  34. 'failed_at' => $this->failed_at?->toISOString(),
  35. 'failure_code' => $this->failure_code,
  36. 'failure_message' => $this->failure_message,
  37. 'gateway_payload' => $this->gateway_payload,
  38. 'metadata' => $this->metadata,
  39. 'created_at' => $this->created_at?->toISOString(),
  40. 'updated_at' => $this->updated_at?->toISOString(),
  41. ];
  42. }
  43. /**
  44. * @param \Illuminate\Database\Eloquent\Collection<PaymentTransfer> $resource
  45. * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection<PaymentTransferResource>
  46. */
  47. public static function collection($resource): AnonymousResourceCollection
  48. {
  49. return parent::collection($resource);
  50. }
  51. }