session()->get('otsLink'); $request->session()->remove('otsLink'); if (! $link) { return redirect()->route('ots.create'); } return Inertia::render('ots/Created', [ 'otsLink' => $link, ]); } public function store(StoreOTSRequest $request): RedirectResponse { $validated = $request->validated(); $ots = OneTimeSecret::create(($validated + ['expires_at' => now()->addMinutes(30)])); $otsLink = route('ots.show', ['oneTimeSecret' => $ots->id]); return redirect()->route('ots.created')->with(['otsLink' => $otsLink]); } public function create(): Response { return Inertia::render('ots/Create', []); } public function show(OneTimeSecret $oneTimeSecret): Response { return Inertia::render('ots/Show', ['oneTimeSecretId' => $oneTimeSecret->id]); } public function reveal(OneTimeSecret $oneTimeSecret): JsonResponse { $oneTimeSecret->delete(); if ($oneTimeSecret->expires_at->isPast()) { abort(404); } return response()->json(['secret' => $oneTimeSecret->secret]); } }