presseportale/app/Http/Controllers/LegacyInvoicePdfController.php
Kevin Adametz a5f3ddd0f3 Optimierung Phase 1: Aufraeumen / toter Code
1.1 Prototyp admin/users/table entfernt: Route (war durch admin/users/{id}
    ohnehin unerreichbar) + Volt-Komponente table.blade.php geloescht,
    ADMIN_ROUTES.md aktualisiert; Regressions-Test in PanelConsolidationTest.
1.2 16 tote Legacy-Wrapper-Views unter resources/views/admin/* geloescht
    (nutzten alte Route-Parameter, nirgends via view/@include/@livewire
    gerendert); admin.dashboard + .md-Doku behalten.
1.3 Tote Helfer entfernt: EnsureUserIsAdmin redundantes loadMissing('roles'),
    ungenutzter statusColor-Key aus with() in admin PR edit/show,
    LegacyInvoicePdfController Laufzeit-Schema::hasColumn (Spalte existiert
    seit Migration) inkl. Schema-Import.

Volle Suite gruen (794 passed, 1 skipped).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 08:27:12 +00:00

29 lines
1 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Models\LegacyInvoice;
use App\Services\Billing\LegacyInvoicePdfRenderer;
use Illuminate\Support\Facades\Gate;
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',
]);
}
$legacyInvoice->forceFill(['pdf_generated_at' => now()])->save();
return $renderer->inlineResponse($legacyInvoice);
}
}