Files
shipping-portal/app/Http/Resources/CurrencyRateResource.php

27 lines
763 B
PHP

<?php
namespace App\Http\Resources;
use App\Classes\ValueObjects\Constants\PaymentMethodType;
use Illuminate\Http\Resources\Json\JsonResource;
class CurrencyRateResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'payment_method' => PaymentMethodType::PAYMENT_METHODS_ID[$this->payment_method_type],
'selling' => [
'type' => property_exists($this->selling, 'type') ? $this->selling->type : 'rate',
'value' => property_exists($this->selling, 'value') ? $this->selling->value : $this->selling
]
];
}
}