ProviderWithdrawalResource.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  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 ProviderWithdrawalResource extends JsonResource
  7. {
  8. public function toArray(Request $request): array
  9. {
  10. return [
  11. 'id' => $this->id,
  12. 'provider_id' => $this->provider_id,
  13. 'provider_name' => $this->provider?->user?->name,
  14. 'recipient_id' => $this->recipient_id,
  15. 'transfer_id' => $this->transfer_id,
  16. 'gross_amount' => $this->gross_amount,
  17. 'gateway_fee_amount' => $this->gateway_fee_amount,
  18. 'net_amount' => $this->net_amount,
  19. 'status' => $this->status,
  20. 'type' => $this->type,
  21. 'bank_account' => $this->bank_account,
  22. 'completed_at' => $this->completed_at?->toISOString(),
  23. 'failed_at' => $this->failed_at?->toISOString(),
  24. 'payment_split_ids' => $this->whenLoaded('paymentSplits', fn () => $this->paymentSplits->pluck('id')->values()),
  25. 'created_at' => $this->created_at?->toISOString(),
  26. ];
  27. }
  28. public static function collection($resource): AnonymousResourceCollection
  29. {
  30. return parent::collection($resource);
  31. }
  32. }