mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 12:33:56 +00:00
30 lines
903 B
PHP
30 lines
903 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class GroupResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'original_amount' => (double) $this->original_amount,
|
|
'original_currency' => new CurrencyResource($this->original_currency),
|
|
'amount' => (double) $this->amount,
|
|
'currency' => new CurrencyResource($this->currency),
|
|
'created_at' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A'),
|
|
'currency_rate' => (float) $this->currency_rate,
|
|
'transactions' => TransactionResource::collection($this->transactions()->get()),
|
|
];
|
|
}
|
|
}
|