update api register

This commit is contained in:
Wian Drs
2026-08-01 11:42:42 +07:00
parent b0d08211ec
commit 75342dc7b7
55 changed files with 2254 additions and 35 deletions
@@ -0,0 +1,25 @@
<?php
namespace App\Http\Resources\Voucher;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class VoucherSaleResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id, 'uuid' => $this->uuid, 'sale_number' => $this->sale_number,
'agent' => $this->whenLoaded('agent'), 'package_profile' => $this->whenLoaded('packageProfile'),
'creator' => $this->whenLoaded('creator'), 'quantity' => $this->quantity, 'unit_price' => $this->unit_price,
'discount_amount' => $this->discount_amount, 'total_amount' => $this->total_amount,
'payment_status' => $this->payment_status, 'status' => $this->status, 'created_at' => $this->created_at,
'vouchers' => $this->whenLoaded('vouchers', fn () => $this->vouchers->map(fn ($voucher) => [
'id' => $voucher->id, 'uuid' => $voucher->uuid, 'username' => $voucher->username,
'password' => $voucher->access_password, 'status' => $voucher->status, 'sync_status' => $voucher->sync_status,
'mikrotik' => $voucher->mikrotik, 'valid_until' => $voucher->valid_until,
])),
];
}
}