forked from TFMM/silent-auction
feat: migrate receipt PDF generation to Spatie Laravel PDF
This commit is contained in:
@@ -6,7 +6,7 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use View;
|
||||
use App\helpers;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf as PDF;
|
||||
use Spatie\LaravelPdf\Facades\Pdf;
|
||||
use App\Models\Bidders;
|
||||
use App\Models\Items;
|
||||
use App\Models\Checkout;
|
||||
@@ -277,22 +277,12 @@ class PagesController extends Controller
|
||||
WHERE winning_bidder_num = $bidder_num
|
||||
GROUP BY winning_bids.winning_bidder_num
|
||||
");
|
||||
$checkout_data = [
|
||||
'checkout_final_results' => $checkout_final_results,
|
||||
'checkout_list_results' => $checkout_list_results,
|
||||
'checkout_info_results' => $checkout_info_results
|
||||
];
|
||||
|
||||
// Configure mPDF to use a writable directory
|
||||
$writableTemp = storage_path('temp');
|
||||
if (!file_exists($writableTemp)) {
|
||||
mkdir($writableTemp, 0755, true);
|
||||
}
|
||||
|
||||
$pdf = PDF::loadView('receiptpdf', $checkout_data);
|
||||
$pdf->getMpdf()->tempDir = $writableTemp;
|
||||
|
||||
return $pdf->download('receipt-'.$checkoutid.'.pdf');
|
||||
|
||||
return Pdf::view('receiptpdf', [
|
||||
'checkout_final_results' => $checkout_final_results,
|
||||
'checkout_list_results' => $checkout_list_results,
|
||||
'checkout_info_results' => $checkout_info_results
|
||||
])->name('receipt-'.$checkoutid.'.pdf');
|
||||
}
|
||||
|
||||
public function reprintReceipt(Request $reprint_receipt_req)
|
||||
|
||||
Reference in New Issue
Block a user