Skip to content

Commit

Permalink
Gestion de la navbar #6
Browse files Browse the repository at this point in the history
  • Loading branch information
Elikill58 committed Nov 23, 2023
1 parent 4d00230 commit a19dd17
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 5 deletions.
6 changes: 6 additions & 0 deletions resources/lang/fr/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,11 @@
'password' => 'Mot de passe',
'perpage' => 'Nombre de sanctions par page',
'prefix' => 'Table prefix',
'features' => [
'title' => 'Fonctionnalité activées',
'kicks' => 'Kicks activé',
'mutes' => 'Mutes activé',
'warns' => 'Avertissements activé'
]
],
];
15 changes: 14 additions & 1 deletion resources/views/admin/settings.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,20 @@
<div class="card-body">
<div class="mb-3">
<label for="perpage" class="form-label">{{ trans('litebans::admin.settings.perpage') }}</label>
<input class="form-control" id="perpage" name="perpage" value="{{ $perpage }}" required="required">
<input class="form-control" type="text" id="perpage" name="perpage" value="{{ $perpage }}" required="required">
</div>
{{ trans('litebans::admin.settings.features.title') }}
<div class="mb-3 form-check">
<input class="form-check-input" type="checkbox" id="mutes_enabled" name="mutes_enabled" {{ $mutes_enabled ? 'checked' : '' }}>
<label class="form-check-label" for="mutes_enabled">{{ trans('litebans::admin.settings.features.mutes') }}</label>
</div>
<div class="mb-3 form-check">
<input class="form-check-input" type="checkbox" id="kicks_enabled" name="kicks_enabled" {{ $kicks_enabled ? 'checked' : '' }}>
<label class="form-check-label" for="kicks_enabled">{{ trans('litebans::admin.settings.features.kicks') }}</label>
</div>
<div class="mb-3 form-check">
<input class="form-check-input" type="checkbox" id="warns_enabled" name="warns_enabled" {{ $warns_enabled ? 'checked' : '' }}>
<label class="form-check-label" for="warns_enabled">{{ trans('litebans::admin.settings.features.warns') }}</label>
</div>

<button type="submit" class="btn btn-primary">
Expand Down
14 changes: 10 additions & 4 deletions resources/views/elements/navbar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item {{ request()->routeIs('litebans.index') ? 'active' : ''}}"><a class="nav-link" href="{{ route('litebans.index') }}">{{ trans('litebans::messages.navigation.bans') }}({{ $bansCount }})</a></li>
<li class="nav-item {{ request()->routeIs('litebans.mute') ? 'active' : ''}}"><a class="nav-link" href="{{ route('litebans.mute') }}">{{ trans('litebans::messages.navigation.mutes') }}({{ $mutesCount }})</a></li>
<li class="nav-item {{ request()->routeIs('litebans.kick') ? 'active' : ''}}"><a class="nav-link" href="{{ route('litebans.kick') }}">{{ trans('litebans::messages.navigation.kicks') }}({{ $kicksCount }})</a></li>
<li class="nav-item {{ request()->routeIs('litebans.warn') ? 'active' : ''}}"><a class="nav-link" href="{{ route('litebans.warn') }}">{{ trans('litebans::messages.navigation.warns') }}({{ $warnsCount }})</a></li>
<li class="nav-item {{ request()->routeIs('litebans.index') ? 'active' : ''}}"><a class="nav-link" href="{{ route('litebans.index') }}">{{ trans('litebans::messages.navigation.bans') }} ({{ $bansCount }})</a></li>
@if(setting('litebans.mutes_enabled', true))
<li class="nav-item {{ request()->routeIs('litebans.mute') ? 'active' : ''}}"><a class="nav-link" href="{{ route('litebans.mute') }}">{{ trans('litebans::messages.navigation.mutes') }} ({{ $mutesCount }})</a></li>
@endif
@if(setting('litebans.kicks_enabled', true))
<li class="nav-item {{ request()->routeIs('litebans.kick') ? 'active' : ''}}"><a class="nav-link" href="{{ route('litebans.kick') }}">{{ trans('litebans::messages.navigation.kicks') }} ({{ $kicksCount }})</a></li>
@endif
@if(setting('litebans.warns_enabled', true))
<li class="nav-item {{ request()->routeIs('litebans.warn') ? 'active' : ''}}"><a class="nav-link" href="{{ route('litebans.warn') }}">{{ trans('litebans::messages.navigation.warns') }} ({{ $warnsCount }})</a></li>
@endif
</ul>
</form>
</div>
Expand Down
9 changes: 9 additions & 0 deletions src/Controllers/Admin/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public function show()
'password' => setting('litebans.password'),
'perpage' => setting('litebans.perpage'),
'prefix' => setting('litebans.prefix', 'litebans_'),
'mutes_enabled' => setting('litebans.mutes_enabled', true),
'kicks_enabled' => setting('litebans.kicks_enabled', true),
'warns_enabled' => setting('litebans.warns_enabled', true),
]);
}

Expand All @@ -36,6 +39,9 @@ public function save(Request $request)
'password' => ['required', 'string', 'max:255'],
'perpage' => ['required', 'integer', 'between:1,100'],
'prefix' => ['required', 'string', 'max:255'],
'mutes_enabled' => ['nullable'],
'kicks_enabled' => ['nullable'],
'warns_enabled' => ['nullable'],
]);

Setting::updateSettings([
Expand All @@ -46,6 +52,9 @@ public function save(Request $request)
'litebans.password' => $validated['password'],
'litebans.prefix' => $validated['prefix'] ?? 'litebans_',
'litebans.perpage' => $validated['perpage'],
'litebans.mutes_enabled' => $request->has('mutes_enabled'),
'litebans.kicks_enabled' => $request->has('kicks_enabled'),
'litebans.warns_enabled' => $request->has('warns_enabled'),
]);

return redirect()->route('litebans.admin.settings')->with('success', trans(trans('admin.settings.updated')));
Expand Down
1 change: 1 addition & 0 deletions src/Controllers/LitebansKickController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class LitebansKickController extends LitebansController
*/
public function index()
{
abort_if(setting('litebans.kicks_enabled') == false, 404);
return view('litebans::kick', ['kicks' => Kick::getKicksList()]);
}
}
1 change: 1 addition & 0 deletions src/Controllers/LitebansMuteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class LitebansMuteController extends LitebansController
*/
public function index()
{
abort_if(setting('litebans.mutes_enabled') == false, 404);
return view('litebans::mute', ['mutes' => Mute::getMutesList()]);
}
}
1 change: 1 addition & 0 deletions src/Controllers/LitebansWarnController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class LitebansWarnController extends LitebansController
*/
public function index()
{
abort_if(setting('litebans.warns_enabled') == false, 404);
return view('litebans::warn', ['warns' => Warning::getWarningsList()]);
}
}

0 comments on commit a19dd17

Please sign in to comment.