clean up wallet

This commit is contained in:
omair saleh
2022-02-10 10:28:26 +08:00
parent e8ff49163d
commit 1585dcfa5a
8 changed files with 112 additions and 76 deletions
@@ -2,6 +2,10 @@
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
@@ -14,17 +18,38 @@ class WalletTransactionResource extends JsonResource
*/
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 [
'id' => $this->id,
'wallet_id' => (int) $this->wallet_id,
'bill_no' => (int) $this->bill_no,
'trans_type'=>(int) $this->trans_type,
'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,
'currency_id' => (int) $this->currency_id,
'original_amount' => (double) $this->original_amount,
'original_currency_id' => (int) $this->original_currency_id,
'currency_rate' => (double) $this->currency_rate,
'reference' => $this->payment_reference
'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')
];
}
}