bugs fix ambil path di list provider
This commit is contained in:
@@ -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 [
|
||||
|
||||
Reference in New Issue
Block a user