Add toggle install status support

This commit is contained in:
Dane Everitt 2016-01-04 16:09:22 -05:00
parent 7314e70372
commit 99a67127c9
3 changed files with 28 additions and 0 deletions

View file

@ -312,4 +312,21 @@ class ServersController extends Controller
]);
}
public function postToggleInstall(Request $request, $id)
{
try {
$server = new ServerRepository;
$server->toggleInstall($id);
Alert::success('Server status was successfully toggled.')->flash();
} catch(\Exception $e) {
Log::error($e);
Alert::danger('An unhandled exception occured while attemping to toggle this servers status.')->flash();
} finally {
return redirect()->route('admin.servers.view', [
'id' => $id,
'tab' => 'tab_manage'
]);
}
}
}

View file

@ -42,6 +42,10 @@ class AdminRoutes {
$router->post('/new/service-variables', [ 'uses' => 'Admin\ServersController@postNewServerServiceVariables' ]);
});
// Change Install Status
$router->post('/view/{id}/installed', [
'uses' => 'Admin\ServersController@postToggleInstall'
]);
});
}

View file

@ -575,4 +575,11 @@ class ServerRepository
}
}
public function toggleInstall($id)
{
$server = Models\Server::findOrFail($id);
$server->installed = ($server->installed === 1) ? 0 : 1;
return $server->save();
}
}