++ fix prioritario display and add link sent toggle

This commit is contained in:
2026-04-13 15:40:35 +00:00
parent 0553d4ef74
commit 6a65087449
10 changed files with 459 additions and 108 deletions

View File

@@ -3,20 +3,32 @@
namespace App\Http\Controllers;
use App\Models\Assegnazione;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
class ShortPdfLinkController extends Controller
{
public function __invoke(string $code): RedirectResponse
public function __invoke(string $code): RedirectResponse|View
{
$assignment = Assegnazione::where('pdf_access_code', $code)->firstOrFail();
abort_unless($assignment->is_aperta, 403);
abort_unless($assignment->territorio?->pdf_path, 404);
// Unauthenticated users (proclamatori) are subject to link TTL
if (! auth()->check()) {
$ttlMonths = max(1, (int) \App\Models\Setting::getValue('assignment_link_ttl_hours', 1));
if ($assignment->assigned_at->copy()->addMonths($ttlMonths)->isPast()) {
return view('assignments.link-scaduto', [
'numero' => $assignment->territorio?->numero,
]);
}
}
return redirect()->route('assignments.pdf.viewer', [
'assignment' => $assignment->id,
'code' => $code,
]);
}
}