3 namespace App\Http\Controllers;
5 use App\Events\UserChanged;
7 use Illuminate\Http\Request;
9 class UserController extends Controller
12 public function setLanguage(Request $request) {
13 $user = $request->user();
16 $validatedData = $request->validate([
17 'language' => 'required|in:de,en',
20 $user->locale = $validatedData['language'];
23 return $user->toJson();
26 public function setStreamLink(Request $request, User $user) {
27 $this->authorize('setStreamLink', $user);
29 $validatedData = $request->validate([
30 'stream_link' => 'required|url',
33 $user->stream_link = $validatedData['stream_link'];
36 UserChanged::dispatch($user);
38 return $user->toJson();
41 public function single(Request $request, $id) {
42 $user = User::findOrFail($id);
43 $this->authorize('view', $user);
44 return $user->toJson();