create toggleWebNotifications method in user controller

This commit is contained in:
2026-03-26 09:14:55 +01:00
parent 78645e3cb0
commit fa58184f21
+13
View File
@@ -363,5 +363,18 @@ class UserController extends Controller
return response()->json(['message' => "Server error"], 500); return response()->json(['message' => "Server error"], 500);
} }
} }
public function togglWebNotifications(Request $request, int $id): JsonResponse {
try {
$user = User::findOrFail($id);
$user->web_notifications = !$user->web_notifications ? 0 : 1;
$user->save();
return response()->json($user);
}catch(\Exception $e){
Log::info($e->getMessage());
return response()->json(['message' => "Server error"], 500);
}
}
} }