改进 支持更新名称

This commit is contained in:
iVampireSP.com 2023-03-02 12:31:07 +08:00
parent c2e2185109
commit 5adb06cd0a
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132

View File

@ -24,12 +24,21 @@ public function index(): JsonResponse
public function update(HostRequest $request, Host $host): JsonResponse
{
$request->validate([
'status' => 'required|in:running,stopped,suspended',
'name' => 'nullable|string|max:255',
'status' => 'nullable|in:running,stopped,suspended',
]);
$status = $host->changeStatus($request->input('status'));
if ($request->filled('name')) {
$host->update([
'name' => $request->input('name'),
]);
}
return $status ? $this->updated($host) : $this->failed('修改失败,请检查是否有足够的余额。');
if ($request->filled('status')) {
$host->changeStatus($request->input('status'));
}
return $this->updated($host);
}
public function destroy(HostRequest $request, Host $host): JsonResponse