Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #17

Merged
merged 2 commits into from
Oct 25, 2024
Merged

Fix #17

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions app/Http/Controllers/PrintController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@
use App\Enums\SizeQrCodeEnum;
use App\Http\Requests\StorePrintRequest;
use App\Models\Asset;
use Barryvdh\DomPDF\Facade\Pdf;
use Illuminate\Http\Response;
use Illuminate\View\View;
use Spatie\LaravelPdf\Enums\Format;
use Spatie\LaravelPdf\Enums\Orientation;
use Spatie\LaravelPdf\Enums\Unit;
use Spatie\LaravelPdf\PdfBuilder;

use function Spatie\LaravelPdf\Support\pdf;

class PrintController extends Controller
{
Expand Down Expand Up @@ -41,7 +37,7 @@ public function index(): View
/**
* Store a newly created resource in storage.
*/
public function store(StorePrintRequest $request): PdfBuilder
public function store(StorePrintRequest $request): Response
{
$id = $request->input('asset_id');
$qty = $request->input('qty');
Expand All @@ -64,13 +60,9 @@ public function store(StorePrintRequest $request): PdfBuilder
],
};

return pdf()->view('prints.pdf.main', compact('asset', 'qty', 'size'))
->headerView('prints.pdf.header', compact('asset'))
->footerView('prints.pdf.footer')
->orientation(Orientation::Portrait)
->format(Format::A4)
->margins(56, 16, 56, 16, Unit::Pixel)
->name(time()."_{$asset->name}.pdf")
->download();
return Pdf::loadView('prints.pdf', compact('asset', 'qty', 'size'))
->setPaper('a4', 'portrait')
->setWarnings(false)
->stream(time()."_{$asset->name}.pdf");
}
}
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
"require": {
"php": "^8.1",
"alhimik1986/php-excel-templator": "^1.0",
"barryvdh/laravel-dompdf": "^3.0",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^10.0",
"laravel/sanctum": "^3.2",
"laravel/tinker": "^2.8",
"phpoffice/phpspreadsheet": "1.29.2",
"renatomarinho/laravel-page-speed": "dev-master",
"santigarcor/laratrust": "^8.3",
"simplesoftwareio/simple-qrcode": "~1",
"spatie/browsershot": "4.2.1",
"spatie/laravel-pdf": "^1.5"
"simplesoftwareio/simple-qrcode": "~1"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
Expand Down
Loading
Loading