mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
e3e4b490b0
# Conflicts: # resources/views/partials/header.blade.php # routes/web.php
37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class WalletResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'code' => $this->code,
|
|
'currency_id' => $this->currency_id,
|
|
'amount' => (double) $this->amount,
|
|
'company_id' => (int) $this->owner->id,
|
|
'transactions' => $this->transactions()->orderBy('id', 'DESC')->get(),
|
|
'topup_transactions' => $this->transactions()->where('type', TransactionType::TOP_UP)->orderBy('id', 'DESC')->get(),
|
|
|
|
// 'transaction' => $this->whenLoaded('transactions', function() {
|
|
// return [
|
|
// 'topup' => $this->transactions
|
|
// ];
|
|
// }),
|
|
// 'transaction' // all
|
|
// 'top_transaction' // only topup
|
|
];
|
|
}
|
|
}
|