PaymentSplitResource.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. 'provider_name' => $this->provider?->user?->name,
  15. 'provider_withdrawal_id' => $this->provider_withdrawal_id,
  16. 'gateway_provider' => $this->gateway_provider,
  17. 'gateway_transfer_target_reference' => $this->gateway_transfer_target_reference,
  18. 'gateway_transfer_target_label' => $this->gateway_transfer_target_label,
  19. 'status' => $this->status,
  20. 'gross_amount' => $this->gross_amount,
  21. 'gateway_fee_amount' => $this->gateway_fee_amount,
  22. 'net_amount' => $this->net_amount,
  23. 'transferred_at' => $this->transferred_at?->toISOString(),
  24. 'metadata' => $this->metadata,
  25. 'payment_status' => $this->payment?->status?->value,
  26. 'payment_paid_at' => $this->payment?->paid_at?->toISOString(),
  27. 'schedule_date' => $this->payment?->schedule?->date,
  28. 'schedule_status' => $this->payment?->schedule?->status,
  29. 'schedule_period_type' => $this->payment?->schedule?->period_type,
  30. 'client_name' => $this->payment?->schedule?->client?->user?->name,
  31. 'created_at' => $this->created_at?->toISOString(),
  32. 'updated_at' => $this->updated_at?->toISOString(),
  33. ];
  34. }
  35. public static function collection($resource): AnonymousResourceCollection
  36. {
  37. return parent::collection($resource);
  38. }
  39. }