forked from TFMM/silent-auction
fix: resolve mPDF temp directory access error by using storage_path
This commit is contained in:
@@ -255,6 +255,10 @@ class PagesController extends Controller
|
|||||||
$checkoutid = $request->checkout_id;
|
$checkoutid = $request->checkout_id;
|
||||||
$checkout_final_results = Checkout::where('checkout_id', '=', $checkoutid)
|
$checkout_final_results = Checkout::where('checkout_id', '=', $checkoutid)
|
||||||
->first();
|
->first();
|
||||||
|
if (!$checkout_final_results) {
|
||||||
|
return redirect('/mywinnings')->with('error', 'Checkout record not found.');
|
||||||
|
}
|
||||||
|
|
||||||
$bidder_num = $checkout_final_results->bidder_num;
|
$bidder_num = $checkout_final_results->bidder_num;
|
||||||
$checkout_list_results = DB::select("SELECT
|
$checkout_list_results = DB::select("SELECT
|
||||||
*, items.item_assigned_num, items.item_desc
|
*, items.item_assigned_num, items.item_desc
|
||||||
@@ -279,7 +283,15 @@ class PagesController extends Controller
|
|||||||
'checkout_info_results' => $checkout_info_results
|
'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');
|
return $pdf->download('receipt-'.$checkoutid.'.pdf');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user