fix: resolve mPDF temp directory access error by using storage_path

This commit is contained in:
2026-05-01 09:38:46 -04:00
parent 98be7131f4
commit 298f3fa22b
+13 -1
View File
@@ -255,6 +255,10 @@ class PagesController extends Controller
$checkoutid = $request->checkout_id;
$checkout_final_results = Checkout::where('checkout_id', '=', $checkoutid)
->first();
if (!$checkout_final_results) {
return redirect('/mywinnings')->with('error', 'Checkout record not found.');
}
$bidder_num = $checkout_final_results->bidder_num;
$checkout_list_results = DB::select("SELECT
*, items.item_assigned_num, items.item_desc
@@ -279,7 +283,15 @@ class PagesController extends Controller
'checkout_info_results' => $checkout_info_results
];
$pdf = PDF::loadView('receiptpdf', $checkout_data);
// Configure mPDF to use a writable directory
$config = [
'tempDir' => storage_path('temp')
];
if (!file_exists(storage_path('temp'))) {
mkdir(storage_path('temp'), 0755, true);
}
$pdf = PDF::loadView('receiptpdf', $checkout_data, [], $config);
return $pdf->download('receipt-'.$checkoutid.'.pdf');
}