12-05-2026 Frontend dev
This commit is contained in:
parent
405df0a122
commit
5b8bdf4182
779 changed files with 480564 additions and 6241 deletions
32
app/Http/Controllers/LegacyInvoicePdfController.php
Normal file
32
app/Http/Controllers/LegacyInvoicePdfController.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\LegacyInvoice;
|
||||
use App\Services\Billing\LegacyInvoicePdfRenderer;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class LegacyInvoicePdfController extends Controller
|
||||
{
|
||||
public function __invoke(LegacyInvoice $legacyInvoice, LegacyInvoicePdfRenderer $renderer): Response
|
||||
{
|
||||
Gate::authorize('downloadPdf', $legacyInvoice);
|
||||
|
||||
if (filled($legacyInvoice->pdf_path) && Storage::disk('local')->exists($legacyInvoice->pdf_path)) {
|
||||
return response()->file(Storage::disk('local')->path($legacyInvoice->pdf_path), [
|
||||
'Content-Type' => 'application/pdf',
|
||||
'Content-Disposition' => 'inline; filename="'.$renderer->filename($legacyInvoice).'"',
|
||||
'Cache-Control' => 'private, max-age=0, must-revalidate',
|
||||
]);
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('legacy_invoices', 'pdf_generated_at')) {
|
||||
$legacyInvoice->forceFill(['pdf_generated_at' => now()])->save();
|
||||
}
|
||||
|
||||
return $renderer->inlineResponse($legacyInvoice);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue