<?php

namespace App\Http\Controllers;

use App\Http\Requests\User\WordCheckRequest;
use App\Models\User;
use Illuminate\Support\Facades\Auth;

class UserController extends Controller
{
    public function first()
    {
        return view('user.first');
    }

    public function storeFirst(WordCheckRequest $request)
    {
        $validated = $request->validated();
        $user = User::where('id', Auth::user()->getAuthIdentifier())->firstOrFail();
        $user->checkword = $validated['checkword'];
        $user->save();
        Auth::setUser($user);

        return response()->json(['success' => true]);
    }
}
