v2board/app/Http/Controllers/Admin/Server/ManageController.php

45 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2020-11-14 17:26:17 +08:00
<?php
namespace App\Http\Controllers\Admin\Server;
use App\Services\ServerService;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
class ManageController extends Controller
{
public function getNodes(Request $request)
{
$serverService = new ServerService();
return response([
2021-06-08 19:07:10 +08:00
'data' => $serverService->getAllServers()
2020-11-14 17:26:17 +08:00
]);
}
public function sort(Request $request)
{
2021-12-28 01:49:33 +08:00
ini_set('post_max_size', '1m');
2023-04-06 16:27:20 +08:00
$params = $request->only(
'shadowsocks',
'vmess',
'trojan',
'hysteria'
) ?? [];
2020-11-14 17:26:17 +08:00
DB::beginTransaction();
2023-04-06 16:27:20 +08:00
foreach ($params as $k => $v) {
$model = 'App\\Models\\Server' . ucfirst($k);
foreach($v as $id => $sort) {
if (!$model::find($id)->update(['sort' => $sort])) {
DB::rollBack();
abort(500, '保存失败');
}
2020-11-14 17:26:17 +08:00
}
}
DB::commit();
return response([
'data' => true
]);
}
}