-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransactionResource.php
35 lines (31 loc) · 1.24 KB
/
TransactionResource.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
namespace Err0r\Laratransaction\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class TransactionResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'transactionable' => $this->whenLoaded('transactionable'),
'status' => new (config('laratransaction.resources.transaction_status'))($this->whenLoaded('status')),
'type' => new (config('laratransaction.resources.transaction_type'))($this->whenLoaded('type')),
'payment_method' => new (config('laratransaction.resources.payment_method'))($this->whenLoaded('paymentMethod')),
'amount' => $this->amount,
'currency' => $this->currency,
// 'gateway' => $this->gateway,
// 'gateway_transaction_id' => $this->gateway_transaction_id,
// 'metadata' => $this->metadata,
'processed_at' => $this->processed_at,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
// 'deleted_at' => $this->deleted_at,
];
}
}