mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 12:33:56 +00:00
56 lines
2.0 KiB
PHP
56 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Classes\General\Eloquent\Filters\TransactionServiceId;
|
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
use App\Models\Transaction;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class WalletTransactionResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
$description = '';
|
|
switch((int) $this->type){
|
|
case 5:
|
|
$description = (double) $this->amount.' Credit Top up';
|
|
break;
|
|
case 9:
|
|
$description = 'Credit Voucher for '.$this->payment_reference;
|
|
break;
|
|
case 1:
|
|
$marking = Transaction::where('payment_reference', $this->bill_no)->first()->owner->marking;
|
|
$description = 'Payment For booking refs.'.'<a href="'.route('booking.details', $marking).'">'.$marking.'</a>';
|
|
break;
|
|
case 11:
|
|
$description = 'Debit Voucher for '.$this->payment_reference;
|
|
break;
|
|
|
|
}
|
|
|
|
return [
|
|
'type' => (int) $this->type,
|
|
'bill_no' => $this->bill_no,
|
|
'reference' => $this->payment_reference,
|
|
'payment_method' => (float) $this->payment_method,
|
|
'issuer_name' => $this->issuerCompany->name,
|
|
'amount' => (double) $this->amount,
|
|
'service_charge' => (double) $this->service_charge,
|
|
'tax' => (double) $this->tax,
|
|
'status' => (int) $this->status,
|
|
'description' => $description,
|
|
'details' => TransactionDetailResource::collection($this->transactionDetails),
|
|
'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y h:i:s A'),
|
|
'created_at' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A')
|
|
];
|
|
}
|
|
}
|