Skip to content

Commit 99a6712

Browse files
committed
Add toggle install status support
1 parent 7314e70 commit 99a6712

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

app/Http/Controllers/Admin/ServersController.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,4 +312,21 @@ public function deleteServer(Request $request, $id, $force = null)
312312
]);
313313
}
314314

315+
public function postToggleInstall(Request $request, $id)
316+
{
317+
try {
318+
$server = new ServerRepository;
319+
$server->toggleInstall($id);
320+
Alert::success('Server status was successfully toggled.')->flash();
321+
} catch(\Exception $e) {
322+
Log::error($e);
323+
Alert::danger('An unhandled exception occured while attemping to toggle this servers status.')->flash();
324+
} finally {
325+
return redirect()->route('admin.servers.view', [
326+
'id' => $id,
327+
'tab' => 'tab_manage'
328+
]);
329+
}
330+
}
331+
315332
}

app/Http/Routes/AdminRoutes.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ public function map(Router $router) {
4242
$router->post('/new/service-variables', [ 'uses' => 'Admin\ServersController@postNewServerServiceVariables' ]);
4343

4444
});
45+
// Change Install Status
46+
$router->post('/view/{id}/installed', [
47+
'uses' => 'Admin\ServersController@postToggleInstall'
48+
]);
4549

4650
});
4751
}

app/Repositories/ServerRepository.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,4 +575,11 @@ public function deleteServer($id, $force)
575575
}
576576
}
577577

578+
public function toggleInstall($id)
579+
{
580+
$server = Models\Server::findOrFail($id);
581+
$server->installed = ($server->installed === 1) ? 0 : 1;
582+
return $server->save();
583+
}
584+
578585
}

0 commit comments

Comments
 (0)