Vourcherify

This commit is contained in:
Dillon
2023-05-30 22:02:09 +08:00
parent 44deab4542
commit 20d6ca47dc
39 changed files with 1102 additions and 35 deletions
+2 -1
View File
@@ -48,7 +48,8 @@ class TransactionResource extends JsonResource
'interval' => [
'value' => $days->gt(Carbon::now()) ? '+' : '-',
'duration' => $days->diff(Carbon::now())->format('%d'),
]
],
'redemption' => new VoucherRedemptionResource($this->voucherRedemption)
];
}
}
@@ -0,0 +1,25 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class VoucherRedemptionResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'voucher_id' => $this->voucher_id,
'transaction_id' => $this->transaction_id,
'redemption_id' => $this->redemption_id,
'value' => (float) $this->value
];
}
}