50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Http\Requests\User\SettingsRequest;
|
|
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]);
|
|
}
|
|
|
|
public function settings()
|
|
{
|
|
return view('user.settings', [
|
|
'settings' => Auth::user()->getSettings(),
|
|
]);
|
|
}
|
|
|
|
public function storeSettings(SettingsRequest $request)
|
|
{
|
|
$validated = $request->validated();
|
|
$user = User::where('id', Auth::user()->getAuthIdentifier())->firstOrFail();
|
|
foreach ($validated as $name => $value) {
|
|
$user->{$name} = $value;
|
|
}
|
|
$user->save();
|
|
Auth::setUser($user);
|
|
|
|
$request->session()->flash('status', __('Settings saved!'));
|
|
|
|
return redirect()->route('user.settings');
|
|
}
|
|
}
|