Selectable game integration

This commit is contained in:
Miguel Nogueira 2021-01-06 01:55:22 +00:00
parent 3e1a75dfea
commit 5cf6b2b241
Signed by: miguel456
GPG Key ID: 2CF61B825316C6A0
3 changed files with 60 additions and 29 deletions

View File

@ -46,7 +46,8 @@ class OptionsController extends Controller
'pwExpiry' => Options::getOption('password_expiry'),
'requiresPMC' => Options::getOption('requireGameLicense'),
'enforce2fa' => Options::getOption('force2fa')
]
],
'currentGame' => Options::getOption('currentGame')
]);
}
@ -89,4 +90,26 @@ class OptionsController extends Controller
return redirect()->back();
}
public function saveGameIntegration(Request $request)
{
$supportedGames = [
'RUST',
'MINECRAFT',
'SE',
'GMOD'
];
if (!is_null($request->gamePref) && in_array($request->gamePref, $supportedGames))
{
Options::changeOption('currentGame', $request->gamePref);
$request->session()->flash('success', 'Updated current game.');
return redirect()->back();
}
$request->session()->flash('error', 'Unsupported game ' . $request->gamePref . '.');
return redirect()->back();
}
}

View File

@ -208,43 +208,48 @@
<div class="card-body">
<div class="form-group mb-3">
<div class="row">
<div class="col">
<label>
<input type="radio" name="gamePref" value="MINECRAFT">
<img alt="Mojang Logo (Minecraft)" height="150px" width="150px" src="/img/mc.jpg">
</label>
</div>
<form method="POST" id="gamePrefForm" action={{ route('saveGameIntegration') }}>
@csrf
@method('PATCH')
<div class="form-group mb-3">
<div class="row">
<div class="col">
<label>
<input type="radio" name="gamePref" value="MINECRAFT" {{ ($currentGame == 'MINECRAFT') ? 'checked' : '' }}>
<img alt="Mojang Logo (Minecraft)" height="150px" width="150px" src="/img/mc.jpg">
</label>
</div>
<div class="col">
<label>
<input type="radio" name="gamePref" value="RUST">
<img alt="Rust Logo" height="150px" width="150px" src="/img/rust.png">
</label>
</div>
<div class="col">
<label>
<input type="radio" name="gamePref" value="RUST" {{ ($currentGame == 'RUST') ? 'checked' : '' }}>
<img alt="Rust Logo" height="150px" width="150px" src="/img/rust.png">
</label>
</div>
<div class="col">
<label>
<input type="radio" name="gamePref" value="GMOD">
<img alt="Gmod Logo" height="150px" width="150px" src="/img/gmod.png">
</label>
</div>
<div class="col">
<label>
<input type="radio" name="gamePref" value="GMOD" {{ ($currentGame == 'GMOD') ? 'checked' : '' }}>
<img alt="Gmod Logo" height="150px" width="150px" src="/img/gmod.png">
</label>
</div>
<div class="col">
<label>
<input type="radio" name="gamePref" value="SE">
<img alt="Gmod Logo" height="150px" width="150px" src="/img/se.png">
</label>
<div class="col">
<label>
<input type="radio" name="gamePref" value="SE" {{ ($currentGame == 'SE') ? 'checked' : '' }}>
<img alt="Gmod Logo" height="150px" width="150px" src="/img/se.png">
</label>
</div>
</div>
</div>
</div>
</form>
</div>
<div class="card-footer">
<button type="button" class="btn btn-success"><i class="fas fa-save"></i> Save Changes</button>
<button onclick="$('#gamePrefForm').submit()" type="button" class="btn btn-success"><i class="fas fa-save"></i> Save Changes</button>
</div>
</div>
</div>

View File

@ -209,6 +209,9 @@ Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['lo
Route::post('settings/security/save', [SecuritySettingsController::class, 'save'])
->name('saveSecuritySettings');
Route::patch('settings/game/update', [OptionsController::class, 'saveGameIntegration'])
->name('saveGameIntegration');
Route::post('players/ban/{user}', [BanController::class, 'insert'])
->name('banUser');