feat: implement server icon customization with AJAX support

This commit is contained in:
2025-12-06 10:06:09 -05:00
parent ecb037ce04
commit b6987ab1e8
4 changed files with 209 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Paymenter\Extensions\Servers\Proxmox\Models\Server;
class ServerIconController extends Controller
{
// Update the icon and color for a server
public function update(Request $request, $serverId)
{
$request->validate([
'icon' => 'nullable|string|max:64',
'color' => 'nullable|string|max:32',
]);
$server = Server::where('id', $serverId)
->where('user_id', Auth::id())
->firstOrFail();
$server->user_set_icon = $request->input('icon');
$server->user_set_icon_color = $request->input('color');
$server->save();
return response()->json(['success' => true]);
}
// Get the icon and color for a server
public function show($serverId)
{
$server = Server::where('id', $serverId)
->where('user_id', Auth::id())
->firstOrFail();
return response()->json([
'icon' => $server->user_set_icon,
'color' => $server->user_set_icon_color,
]);
}
}