]> git.localhorst.tv Git - alttp.git/blob - app/Http/Controllers/UserController.php
add language switcher
[alttp.git] / app / Http / Controllers / UserController.php
1 <?php
2
3 namespace App\Http\Controllers;
4
5 use Illuminate\Http\Request;
6
7 class UserController extends Controller
8 {
9
10         public function setLanguage(Request $request) {
11                 $user = $request->user();
12                 if (!$user) return;
13
14                 $validatedData = $request->validate([
15                         'language' => 'required|in:de,en',
16                 ]);
17
18                 $user->locale = $validatedData['language'];
19                 $user->update();
20
21                 return $user->toJson();
22         }
23
24 }