Skip to content

Commit

Permalink
Add Search, Alert Box & Change Avatar Api
Browse files Browse the repository at this point in the history
  • Loading branch information
ApixPlay committed Feb 23, 2021
1 parent c6937df commit 1a4b16e
Show file tree
Hide file tree
Showing 12 changed files with 317 additions and 302 deletions.
4 changes: 2 additions & 2 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "litebans",
"name": "LiteBans",
"description": "Display the LiteBans punishments on your website.",
"version": "1.0.0",
"version": "1.0.2",
"url": "https://azuriom.com",
"authors": [
"Bryan M."
Expand All @@ -11,4 +11,4 @@
"\\Azuriom\\Plugin\\Litebans\\Providers\\LitebansServiceProvider",
"\\Azuriom\\Plugin\\Litebans\\Providers\\RouteServiceProvider"
]
}
}
20 changes: 15 additions & 5 deletions resources/views/elements/navbar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,21 @@
({{ $warnsCount }})</a>
</li>
</ul>
{{-- <form class="form-inline my-2 my-lg-0" action="{{URL::to('/litebans/history')}}" method="GET" role="search">
<input class="form-control mr-sm-2" type="search"
placeholder="{{ trans('litebans::messages.navigation.search') }}" aria-label="Search" name="uuid">
<button class="btn btn-primary my-2 my-sm-0" type="submit"><i class="fas fa-search"></i></button>
</form> --}}
<form class="form-inline my-2 my-lg-0" action="{{ route('litebans.search') }}" method="GET">
<input class="form-control mr-sm-2" type="text"
placeholder="{{ trans('litebans::messages.navigation.search') }}" aria-label="Search" name="q">
<button class="btn btn-primary my-2 my-sm-0" type="submit"><i class="fas fa-search"></i></button>
</form>
</div>
</div>
</nav>

@if(session()->has('error-search'))
<div class="alert alert-danger alert-search alert-dismissible fade show mt-3" role="alert">
<i class="fas fa-exclamation-circle"></i>
{{ session()->get('error-search') }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
@endif
422 changes: 210 additions & 212 deletions resources/views/history.blade.php

Large diffs are not rendered by default.

76 changes: 38 additions & 38 deletions resources/views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,54 @@
@section('title', trans('litebans::messages.navigation.warns'))

@section('content')
<div class="container content">
@include('litebans::elements.navbar')
<div class="container content">
@include('litebans::elements.navbar')

<table class="table table-striped table-hover mt-4">
<thead>
<table class="table table-striped table-hover mt-4">
<thead>
<tr>
<th scope="col">{{ trans('litebans::messages.username') }}</th>
<th scope="col">{{ trans('litebans::messages.staff_ban') }}</th>
<th scope="col" class="d-lg-table-cell d-none">{{ trans('litebans::messages.reason') }}</th>
<th scope="col">{{ trans('messages.fields.date') }}</th>
<th scope="col" class="d-lg-table-cell d-none">{{ trans('litebans::messages.expires_at') }}</th>
</tr>
</thead>
<tbody>
</thead>
<tbody>
@forelse ($bans as $ban)
<tr class="text-nowrap">
<td>
<a href="{{ route('litebans.history', $ban->uuid) }}">
<img src="https://minotar.net/avatar/{{ $ban->name }}/25" alt="{{ $ban->name }}">
{{ $ban->name }}
</a>
</td>
<td>
<a href="{{ route('litebans.history.issued', $ban->banned_by_uuid) }}">
{{ $ban->banned_by_name }}
</a>
</td>
<td class="d-lg-table-cell d-none">{{ $ban->reason }}</td>
<td>{{ format_date($ban->time) }}</td>
<tr class="text-nowrap">
<td>
<a href="{{ route('litebans.history', $ban->name) }}">
<img src="https://cravatar.eu/avatar/{{ $ban->name }}/25" alt="{{ $ban->name }}">
{{ $ban->name }}
</a>
</td>
<td>
<a href="{{ route('litebans.history.issued', $ban->banned_by_name) }}">
{{ $ban->banned_by_name }}
</a>
</td>
<td class="d-lg-table-cell d-none">{{ $ban->reason }}</td>
<td>{{ format_date($ban->time) }}</td>

@if(isset($ban->removed_by_name))
<td class="d-lg-table-cell d-none">{{ trans('litebans::messages.unbanned') }}</td>
@elseif($ban->until === null)
<td class="d-lg-table-cell d-none">{{ trans('litebans::messages.permanent') }}</td>
@elseif($ban->until->isPast())
<td class="d-lg-table-cell d-none">{{ trans('litebans::messages.expired') }}</td>
@else
<td class="d-lg-table-cell d-none">{{ format_date($ban->until) }}</td>
@endif
</tr>
@if(isset($ban->removed_by_name))
<td class="d-lg-table-cell d-none">{{ trans('litebans::messages.unbanned') }}</td>
@elseif($ban->until === null)
<td class="d-lg-table-cell d-none">{{ trans('litebans::messages.permanent') }}</td>
@elseif($ban->until->isPast())
<td class="d-lg-table-cell d-none">{{ trans('litebans::messages.expired') }}</td>
@else
<td class="d-lg-table-cell d-none">{{ format_date($ban->until) }}</td>
@endif
</tr>
@empty
<tr>
<td colspan="7" class="text-center">{{ trans('litebans::messages.no_punishments_found') }}</td>
</tr>
<tr>
<td colspan="7" class="text-center">{{ trans('litebans::messages.no_punishments_found') }}</td>
</tr>
@endforelse
</tbody>
</table>
</tbody>
</table>

{{ $bans->withQueryString()->links() }}
</div>
@endsection
{{ $bans->withQueryString()->links() }}
</div>
@endsection
8 changes: 4 additions & 4 deletions resources/views/kick.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
@forelse ($kicks as $kick)
<tr class="text-nowrap">
<td>
<a href="{{ route('litebans.history', $kick->uuid) }}">
<img src="https://minotar.net/avatar/{{ $kick->name }}/25" alt="{{ $kick->name }}">
<a href="{{ route('litebans.history', $kick->name) }}">
<img src="https://cravatar.eu/avatar/{{ $kick->name }}/25" alt="{{ $kick->name }}">
{{ $kick->name }}
</a>
</td>
<td>
<a href="{{ route('litebans.history.issued', $kick->banned_by_uuid) }}">
<a href="{{ route('litebans.history.issued', $kick->banned_by_name) }}">
{{ $kick->banned_by_name }}
</a>
</td>
Expand All @@ -42,4 +42,4 @@

{{ $kicks->withQueryString()->links() }}
</div>
@endsection
@endsection
16 changes: 8 additions & 8 deletions resources/views/mute.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@
@forelse ($mutes as $mute)
<tr class="text-nowrap">
<td>
<a href="{{ route('litebans.history', $mute->uuid) }}">
<img src="https://minotar.net/avatar/{{ $mute->name }}/25" alt="{{ $mute->name }}">
<a href="{{ route('litebans.history', $mute->name) }}">
<img src="https://cravatar.eu/avatar/{{ $mute->name }}/25" alt="{{ $mute->name }}">
{{ $mute->name }}
</a>
</td>
<td>
<a href="{{ route('litebans.history.issued', $mute->banned_by_uuid) }}">
<a href="{{ route('litebans.history.issued', $mute->banned_by_name) }}">
{{ $mute->banned_by_name }}
</a>
</td>
<td class="d-lg-table-cell d-none">{{ $mute->reason }}</td>
<td>{{ format_date($mute->time) }}</td>
@if(isset($mute->removed_by_name))
<td class="d-lg-table-cell d-none">{{ trans('litebans::messages.unbanned') }}</td>
<td class="d-lg-table-cell d-none">{{ trans('litebans::messages.unbanned') }}</td>
@elseif($mute->until === null)
<td class="d-lg-table-cell d-none">{{ trans('litebans::messages.permanent') }}</td>
<td class="d-lg-table-cell d-none">{{ trans('litebans::messages.permanent') }}</td>
@elseif($mute->until->isPast())
<td class="d-lg-table-cell d-none">{{ trans('litebans::messages.expired') }}</td>
<td class="d-lg-table-cell d-none">{{ trans('litebans::messages.expired') }}</td>
@else
<td class="d-lg-table-cell d-none">{{ format_date($mute->until) }}</td>
<td class="d-lg-table-cell d-none">{{ format_date($mute->until) }}</td>
@endif
</tr>
@empty
Expand All @@ -52,4 +52,4 @@

{{ $mutes->withQueryString()->links() }}
</div>
@endsection
@endsection
16 changes: 8 additions & 8 deletions resources/views/warn.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
@forelse ($warns as $warn)
<tr class="text-nowrap">
<td>
<a href="{{ route('litebans.history', $warn->uuid) }}">
<img src="https://minotar.net/avatar/{{ $warn->name }}/25" alt="{{ $warn->name }}">
<a href="{{ route('litebans.history', $warn->name) }}">
<img src="https://cravatar.eu/avatar/{{ $warn->name }}/25" alt="{{ $warn->name }}">
{{ $warn->name }}
</a>
</td>
<td>
<a href="{{ route('litebans.history.issued', $warn->banned_by_uuid) }}">
<a href="{{ route('litebans.history.issued', $warn->banned_by_name) }}">
{{ $warn->banned_by_name }}
</a>
</td>
Expand All @@ -36,13 +36,13 @@
<td>{{ format_date($warn->time) }}</td>

@if(isset($warn->removed_by_name))
<td class="d-lg-table-cell d-none">{{ trans('litebans::messages.unbanned') }}</td>
<td class="d-lg-table-cell d-none">{{ trans('litebans::messages.unbanned') }}</td>
@elseif($warn->until === null)
<td class="d-lg-table-cell d-none">{{ trans('litebans::messages.permanent') }}</td>
<td class="d-lg-table-cell d-none">{{ trans('litebans::messages.permanent') }}</td>
@elseif($warn->until->isPast())
<td class="d-lg-table-cell d-none">{{ trans('litebans::messages.expired') }}</td>
<td class="d-lg-table-cell d-none">{{ trans('litebans::messages.expired') }}</td>
@else
<td class="d-lg-table-cell d-none">{{ format_date($warn->until) }}</td>
<td class="d-lg-table-cell d-none">{{ format_date($warn->until) }}</td>
@endif
</tr>
@empty
Expand All @@ -55,4 +55,4 @@

{{ $warns->withQueryString()->links() }}
</div>
@endsection
@endsection
9 changes: 3 additions & 6 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
Route::get('/mutes', 'LitebansMuteController@index')->name('mute');
Route::get('/kicks', 'LitebansKickController@index')->name('kick');
Route::get('/warns', 'LitebansWarnController@index')->name('warn');
Route::get('/history/{uuid}', 'LitebansHistoryController@index')->name('history');
Route::get('/history/{uuid}/staff', 'LitebansHistoryController@issued')->name('history.issued');

/*Route::get('/history', function (Request $request) {
return History::connection('litebans')->search($request->search)->get();
});*/
Route::get('/history/{name}', 'LitebansHistoryController@index')->name('history');
Route::get('/history/{name}/staff', 'LitebansHistoryController@issued')->name('history.issued');
Route::get('/search', 'LitebansController@search')->name('search');
17 changes: 17 additions & 0 deletions src/Controllers/LitebansController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
use Azuriom\Plugin\Litebans\Models\Kick;
use Azuriom\Plugin\Litebans\Models\Mute;
use Azuriom\Plugin\Litebans\Models\Warning;
use Azuriom\Plugin\Litebans\Models\History;
use Illuminate\Support\Facades\View;
use Illuminate\Http\Request;

class LitebansController extends Controller
{
Expand Down Expand Up @@ -37,4 +39,19 @@ public function __construct()
'kicksCount' => Kick::count(),
]);
}


public function search(Request $request)
{
$key = $request->input('q');

if ($key != null) {
return redirect()->route('litebans.history', $key);
}
return back()->with('error-search', "Cet utilisateur n'existe pas !");

/*$search = History::select('uuid')
->where('name', 'like', "%{$key}%")
->get();*/
}
}
16 changes: 10 additions & 6 deletions src/Controllers/LitebansHistoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ class LitebansHistoryController extends LitebansController
* @param string $uuid
* @return \Illuminate\Http\Response
*/
public function index(string $uuid)
public function index(string $name)
{
$name = History::where('uuid', $uuid)->value('name');
$uuid = History::where('name', $name)->value('uuid');

abort_if($name === null, 404);
if ($uuid === null) {
return back()->with('error-search', "Cet utilisateur n'existe pas");
}

$user = [
'name' => $name,
Expand All @@ -27,11 +29,13 @@ public function index(string $uuid)
return view('litebans::history', array_merge(History::getUserHistory($uuid), $user));
}

public function issued(string $uuid)
public function issued(string $name)
{
$name = History::where('uuid', $uuid)->value('name');
$uuid = History::where('name', $name)->value('uuid');

abort_if($name === null, 404);
if ($uuid === null) {
return back()->with('error-search', "Cet utilisateur n'existe pas");
}

$user = [
'name' => $name,
Expand Down
13 changes: 1 addition & 12 deletions src/Controllers/LitebansHomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Azuriom\Plugin\Litebans\Controllers;

use Azuriom\Plugin\Litebans\Models\Ban;
use Illuminate\Http\Request;

class LitebansHomeController extends LitebansController
{
Expand All @@ -12,20 +11,10 @@ class LitebansHomeController extends LitebansController
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
public function index()
{
/*$search = $request->input('search');
$searchvalue = History::getUuid($search);
$userhistory = History::when($searchvalue, function (Builder $query, string $search) {
$query->scopes(['search' => $search]);
})->get();*/

return view('litebans::index', [
'bans' => Ban::getBansList(),
//'search' => $search,
//'userhistory' => $userhistory,
]);
}
}
2 changes: 1 addition & 1 deletion src/Models/History.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class History extends Model
* @var array
*/
protected $searchable = [
'name', 'uuid',
'name',
];

public static function getUserHistory(string $uuid)
Expand Down

0 comments on commit 1a4b16e

Please sign in to comment.