改进 支持更新名称
This commit is contained in:
parent
c2e2185109
commit
5adb06cd0a
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user