bugs fix ambil path di list provider

This commit is contained in:
Server D3 Linksehat
2025-08-27 16:30:44 +07:00
parent 9900c00b8d
commit a9423e8b0a
6 changed files with 279 additions and 39 deletions

View File

@@ -241,11 +241,34 @@ class InvoicePaymentController extends Controller
'files.id as file_id',
'invoice_payments.amount_paid',
'invoice_payments.payment_number',
DB::raw("CONCAT('" . env('APP_URL') . "/storage/', files.path) as path"),
'files.path',
'files.source',
'files.original_name'
)
->orderBy('invoice_payments.payment_number', 'asc')
->get();
->get()
->map(function ($row) {
// default null kalau tidak ada path
if (!$row->path) {
$row->path = null; // atau bisa $row->url = null
return $row;
}
if ($row->source === 's3') {
try {
$row->path = Storage::disk('s3')->temporaryUrl(
$row->path,
now()->addMinutes(60)
);
} catch (\Exception $e) {
$row->path = Storage::disk('s3')->url($row->path);
}
} else {
$row->path = Storage::disk('public')->url($row->path);
}
return $row;
});
$invoice['files'] = $payments->groupBy('payment_number')->map(function ($group) {
return [