PaymentSplitResource.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Http\Resources;
  3. use Illuminate\Http\Request;
  4. use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
  5. use Illuminate\Http\Resources\Json\JsonResource;
  6. class PaymentSplitResource extends JsonResource
  7. {
  8. public function toArray(Request $request): array
  9. {
  10. return [
  11. 'id' => $this->id,
  12. 'payment_id' => $this->payment_id,
  13. 'provider_id' => $this->provider_id,
  14. 'gateway_provider' => $this->gateway_provider,
  15. 'gateway_transfer_target_reference' => $this->gateway_transfer_target_reference,
  16. 'gateway_transfer_target_label' => $this->gateway_transfer_target_label,
  17. 'status' => $this->status,
  18. 'gross_amount' => $this->gross_amount,
  19. 'gateway_fee_amount' => $this->gateway_fee_amount,
  20. 'net_amount' => $this->net_amount,
  21. 'transferred_at' => $this->transferred_at?->toISOString(),
  22. 'metadata' => $this->metadata,
  23. 'payment_status' => $this->payment?->status?->value,
  24. 'payment_paid_at' => $this->payment?->paid_at?->toISOString(),
  25. 'schedule_date' => $this->payment?->schedule?->date,
  26. 'schedule_status' => $this->payment?->schedule?->status,
  27. 'schedule_period_type' => $this->payment?->schedule?->period_type,
  28. 'client_name' => $this->payment?->schedule?->client?->user?->name,
  29. 'created_at' => $this->created_at?->toISOString(),
  30. 'updated_at' => $this->updated_at?->toISOString(),
  31. ];
  32. }
  33. public static function collection($resource): AnonymousResourceCollection
  34. {
  35. return parent::collection($resource);
  36. }
  37. }