mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +08:00
54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\Server;
|
|
|
|
use App\Models\ServerV2ray;
|
|
use App\Models\ServerShadowsocks;
|
|
use App\Models\ServerTrojan;
|
|
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([
|
|
'data' => $serverService->getAllServers()
|
|
]);
|
|
}
|
|
|
|
public function sort(Request $request)
|
|
{
|
|
DB::beginTransaction();
|
|
foreach ($request->input('sorts') as $k => $v) {
|
|
switch ($v['key']) {
|
|
case 'shadowsocks':
|
|
if (!ServerShadowsocks::find($v['value'])->update(['sort' => $k + 1])) {
|
|
DB::rollBack();
|
|
abort(500, '保存失败');
|
|
}
|
|
break;
|
|
case 'v2ray':
|
|
if (!ServerV2ray::find($v['value'])->update(['sort' => $k + 1])) {
|
|
DB::rollBack();
|
|
abort(500, '保存失败');
|
|
}
|
|
break;
|
|
case 'trojan':
|
|
if (!ServerTrojan::find($v['value'])->update(['sort' => $k + 1])) {
|
|
DB::rollBack();
|
|
abort(500, '保存失败');
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
DB::commit();
|
|
return response([
|
|
'data' => true
|
|
]);
|
|
}
|
|
}
|