改进 状态管理
This commit is contained in:
parent
84f5da51a1
commit
6dd4caef5c
@ -22,12 +22,17 @@ public function index(): JsonResponse
|
|||||||
return $this->success($hosts);
|
return $this->success($hosts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
public function update(Request $request, Host $host): JsonResponse
|
public function update(Request $request, Host $host): JsonResponse
|
||||||
{
|
{
|
||||||
|
$request->validate([
|
||||||
|
'status' => 'required|in:running,stopped',
|
||||||
|
]);
|
||||||
|
|
||||||
$user = $request->user();
|
$user = $request->user();
|
||||||
if ($host->user_id == $user->id) {
|
if ($host->user_id == $user->id) {
|
||||||
$host->update([
|
$host->update([
|
||||||
'status' => 'running'
|
'status' => $request->status,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->updated($host);
|
return $this->updated($host);
|
||||||
|
Loading…
Reference in New Issue
Block a user