Session::get('verify.result')]); } public function check(Request $request): RedirectResponse { $validated = $request->validate([ 'certificate_number' => ['required', 'string', 'max:255'], 'holder_last_name' => ['required', 'string', 'max:255'], 'cf-turnstile-response' => [new Turnstile], ]); $isValid = Certificate::query() // Verification checks across every account's certificates, not // just the caller's — bypass the owner scope explicitly since a // staff member checking a certificate may be logged in too. ->withoutGlobalScope(OwnedByUserScope::class) ->whereRaw('LOWER(certificate_number) = ?', [Str::lower(trim($validated['certificate_number']))]) ->whereRaw('LOWER(holder_last_name) = ?', [Str::lower(trim($validated['holder_last_name']))]) ->where('expires_at', '>=', today()) ->exists(); return redirect()->route('verify.show') ->with('verify.result', $isValid ? 'valid' : 'invalid'); } }