feat: migrate receipt PDF generation to Spatie Laravel PDF

This commit is contained in:
2026-05-01 09:56:16 -04:00
parent b9c018a4a6
commit 9d981f3a34
3 changed files with 164 additions and 19 deletions
+4 -14
View File
@@ -6,7 +6,7 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use View; use View;
use App\helpers; use App\helpers;
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf as PDF; use Spatie\LaravelPdf\Facades\Pdf;
use App\Models\Bidders; use App\Models\Bidders;
use App\Models\Items; use App\Models\Items;
use App\Models\Checkout; use App\Models\Checkout;
@@ -277,22 +277,12 @@ class PagesController extends Controller
WHERE winning_bidder_num = $bidder_num WHERE winning_bidder_num = $bidder_num
GROUP BY winning_bids.winning_bidder_num GROUP BY winning_bids.winning_bidder_num
"); ");
$checkout_data = [
return Pdf::view('receiptpdf', [
'checkout_final_results' => $checkout_final_results, 'checkout_final_results' => $checkout_final_results,
'checkout_list_results' => $checkout_list_results, 'checkout_list_results' => $checkout_list_results,
'checkout_info_results' => $checkout_info_results 'checkout_info_results' => $checkout_info_results
]; ])->name('receipt-'.$checkoutid.'.pdf');
// 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');
} }
public function reprintReceipt(Request $reprint_receipt_req) public function reprintReceipt(Request $reprint_receipt_req)
+2 -1
View File
@@ -14,7 +14,8 @@
"laravel/socialite": "^5.26", "laravel/socialite": "^5.26",
"laravel/tinker": "^2.9", "laravel/tinker": "^2.9",
"laravel/ui": "^4.2", "laravel/ui": "^4.2",
"socialiteproviders/manager": "^4.9" "socialiteproviders/manager": "^4.9",
"spatie/laravel-pdf": "^2.8"
}, },
"require-dev": { "require-dev": {
"barryvdh/laravel-debugbar": "^3.8", "barryvdh/laravel-debugbar": "^3.8",
Generated
+155 -1
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "3c08b43425d232f81481839d3c2286fc", "content-hash": "91ae6772f9ad6590dc3dafcf7b4899fe",
"packages": [ "packages": [
{ {
"name": "barryvdh/laravel-snappy", "name": "barryvdh/laravel-snappy",
@@ -6220,6 +6220,99 @@
], ],
"time": "2026-02-21T12:49:54+00:00" "time": "2026-02-21T12:49:54+00:00"
}, },
{
"name": "spatie/laravel-pdf",
"version": "2.8.0",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-pdf.git",
"reference": "2ba286a03ee5e22463fb0a6e706b157a21d5f60a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-pdf/zipball/2ba286a03ee5e22463fb0a6e706b157a21d5f60a",
"reference": "2ba286a03ee5e22463fb0a6e706b157a21d5f60a",
"shasum": ""
},
"require": {
"illuminate/contracts": "^11.0|^12.0|^13.0",
"php": "^8.2",
"spatie/laravel-package-tools": "^1.16.1",
"spatie/temporary-directory": "^2.2.1"
},
"require-dev": {
"chrome-php/chrome": "^1.0",
"dompdf/dompdf": "^3.0",
"ext-imagick": "*",
"larastan/larastan": "^2.7.0|^3.0",
"laravel/pint": "^1.13.7",
"nunomaduro/collision": "^8.0",
"orchestra/testbench": "^9.6|^10.0|^11.0",
"pestphp/pest": "^2.30|^3.7|^4.4",
"pestphp/pest-plugin-arch": "^2.5|^3.0|^4.0",
"pestphp/pest-plugin-laravel": "^2.2|^3.1|^4.1",
"phpstan/extension-installer": "^1.3.1",
"phpstan/phpstan-deprecation-rules": "^1.1.4|^2.0",
"phpstan/phpstan-phpunit": "^1.3.15|^2.0",
"pontedilana/php-weasyprint": "^2.4",
"spatie/image": "^3.3.2",
"spatie/invade": "^2.1",
"spatie/laravel-ray": "^1.33",
"spatie/pdf-to-image": "^2.2|^3.1",
"spatie/pdf-to-text": "^1.52.1",
"spatie/pest-expectations": "^1.5",
"spatie/pest-plugin-snapshots": "^2.1",
"spatie/pixelmatch-php": "^1.0",
"wnx/sidecar-browsershot": "^2.0"
},
"suggest": {
"chrome-php/chrome": "Required for the Chrome PHP driver (^1.0)",
"dompdf/dompdf": "Required for the DOMPDF driver (^3.0)",
"spatie/browsershot": "Required for the Browsershot driver (^4.0|^5.0)"
},
"type": "library",
"extra": {
"laravel": {
"aliases": {
"LaravelPdf": "Pdf"
},
"providers": [
"Spatie\\LaravelPdf\\PdfServiceProvider"
]
}
},
"autoload": {
"files": [
"src/Support/functions.php"
],
"psr-4": {
"Spatie\\LaravelPdf\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"role": "Developer"
}
],
"description": "Create PDFs in Laravel apps",
"homepage": "https://github.com/spatie/laravel-pdf",
"keywords": [
"laravel",
"laravel-pdf",
"spatie"
],
"support": {
"issues": "https://github.com/spatie/laravel-pdf/issues",
"source": "https://github.com/spatie/laravel-pdf/tree/2.8.0"
},
"time": "2026-04-27T08:15:52+00:00"
},
{ {
"name": "spatie/shiki-php", "name": "spatie/shiki-php",
"version": "2.3.3", "version": "2.3.3",
@@ -6285,6 +6378,67 @@
], ],
"time": "2026-02-01T09:30:04+00:00" "time": "2026-02-01T09:30:04+00:00"
}, },
{
"name": "spatie/temporary-directory",
"version": "2.3.1",
"source": {
"type": "git",
"url": "https://github.com/spatie/temporary-directory.git",
"reference": "662e481d6ec07ef29fd05010433428851a42cd07"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/temporary-directory/zipball/662e481d6ec07ef29fd05010433428851a42cd07",
"reference": "662e481d6ec07ef29fd05010433428851a42cd07",
"shasum": ""
},
"require": {
"php": "^8.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Spatie\\TemporaryDirectory\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Alex Vanderbist",
"email": "alex@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Easily create, use and destroy temporary directories",
"homepage": "https://github.com/spatie/temporary-directory",
"keywords": [
"php",
"spatie",
"temporary-directory"
],
"support": {
"issues": "https://github.com/spatie/temporary-directory/issues",
"source": "https://github.com/spatie/temporary-directory/tree/2.3.1"
},
"funding": [
{
"url": "https://spatie.be/open-source/support-us",
"type": "custom"
},
{
"url": "https://github.com/spatie",
"type": "github"
}
],
"time": "2026-01-12T07:42:22+00:00"
},
{ {
"name": "symfony/clock", "name": "symfony/clock",
"version": "v8.0.8", "version": "v8.0.8",