26 lines
1.2 KiB
PHP
26 lines
1.2 KiB
PHP
<?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,
|
|
])),
|
|
];
|
|
}
|
|
}
|