增加 Host 解除暂停
This commit is contained in:
parent
fad97f879e
commit
6608853946
@ -20,6 +20,25 @@ public function index(Module $module)
|
||||
return $this->success($hosts);
|
||||
}
|
||||
|
||||
public function update(Request $request, Host $host)
|
||||
{
|
||||
$user = $request->user();
|
||||
if ($host->user_id == $user->id) {
|
||||
|
||||
if ($user->balance < 0) {
|
||||
return $this->error('余额不足');
|
||||
}
|
||||
|
||||
$host->update($request->only(['status']));
|
||||
|
||||
return $this->updated($host);
|
||||
} else {
|
||||
return $this->error('无权操作');
|
||||
}
|
||||
|
||||
return $this->deleted($host);
|
||||
}
|
||||
|
||||
public function destroy(Host $host)
|
||||
{
|
||||
if ($host->user_id == auth()->id()) {
|
||||
@ -29,7 +48,6 @@ public function destroy(Host $host)
|
||||
}
|
||||
|
||||
return $this->deleted($host);
|
||||
|
||||
}
|
||||
|
||||
// /**
|
||||
|
@ -13,8 +13,7 @@
|
||||
Route::name('api.')->middleware(['api', 'auth:sanctum'])->group(function () {
|
||||
Route::apiResource('users', UserController::class);
|
||||
Route::get('servers', ServerController::class);
|
||||
Route::get('hosts', [HostController::class, 'index']);
|
||||
Route::delete('hosts/{host}', [HostController::class, 'destroy']);
|
||||
Route::apiResource('hosts', HostController::class)->only(['index', 'update', 'destroy']);
|
||||
|
||||
|
||||
Route::apiResource('balances', BalanceController::class)->only(['index', 'store']);
|
||||
|
Loading…
Reference in New Issue
Block a user