diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml index 0bf73cf3..37d6767c 100644 --- a/.github/workflows/laravel.yml +++ b/.github/workflows/laravel.yml @@ -63,6 +63,9 @@ jobs: - name: PHPCS run: vendor/bin/pint --test + - name: Check PSR Violations + run: composer dump-autoload --strict-psr + - name: Execute tests (With Coverage) via PHPUnit env: DB_PORT: ${{ job.services.maria.ports[3306] }} diff --git a/app/Http/Controllers/ListController.php b/app/Http/Controllers/ListController.php new file mode 100644 index 00000000..fb5e5089 --- /dev/null +++ b/app/Http/Controllers/ListController.php @@ -0,0 +1,17 @@ +with('latestBan.player') + ->whereHas('latestBan', fn ($query) => $query->whereDate('ends_at', '>=', now())) + ->where('is_cheater', true) + ->orderBy('gamertag') + ->paginate(); + + return view('livewire.banned-player-table', [ + 'players' => $players, + ]); + } +} diff --git a/app/Models/Player.php b/app/Models/Player.php index 4c8a67e5..333dd00a 100644 --- a/app/Models/Player.php +++ b/app/Models/Player.php @@ -69,6 +69,7 @@ * @property-read Collection $bans * @property-read Collection $medals * @property-read Collection $analytics + * @property-read PlayerBan|null $latestBan * @property-read ServiceRecord $serviceRecord * @property-read ServiceRecord $serviceRecordPvp * @property-read string $url_safe_gamertag @@ -419,6 +420,11 @@ public function bans(): HasMany return $this->hasMany(PlayerBan::class); } + public function latestBan(): HasOne + { + return $this->hasOne(PlayerBan::class)->latestOfMany(); + } + public function medals(): HasMany { return $this->hasMany(MedalAnalytic::class); diff --git a/app/Models/PlayerBan.php b/app/Models/PlayerBan.php index 486d3d00..38df9998 100644 --- a/app/Models/PlayerBan.php +++ b/app/Models/PlayerBan.php @@ -21,6 +21,8 @@ * @property string $scope * @property-read Player $player * @property-read bool $is_expired + * @property-read string $days_remaining + * @property-read string $short_message * * @method static PlayerBanFactory factory(...$parameters) */ @@ -49,6 +51,16 @@ public function getMessageAttribute(string $value): string return (string) str_replace(array_keys($replacements), $replacements, $value); } + public function getShortMessageAttribute(): string + { + return Str::beforeLast($this->message, $this->player->gamertag); + } + + public function getDaysRemainingAttribute(): string + { + return number_format($this->ends_at->diffInDays(absolute: true)); + } + public function getIsExpiredAttribute(): bool { return $this->ends_at->isPast(); diff --git a/resources/views/livewire/banned-player-table.blade.php b/resources/views/livewire/banned-player-table.blade.php new file mode 100644 index 00000000..5886a8fb --- /dev/null +++ b/resources/views/livewire/banned-player-table.blade.php @@ -0,0 +1,60 @@ + +
+

Banned Halo Infinite Players

+

A collection of banned players that Leaf knows about.

+
+ + + + + + + + + + + @foreach ($players as $player) + + + + + + + @endforeach + +
GamertagReasonScopeExpiration
+
+
+

+ emblem +

+
+
+
+ @include('partials.links.player', ['player' => $player]) + @if ($player->is_donator) + + + + @endif + @if ($player->is_cheater) + Cheater + @endif + @if ($player->is_botfarmer) + Farmer + @endif +
+
+
+
+ {{ $player->latestBan->short_message }} + {{ $player->latestBan->scope }}, {{ $player->latestBan->type }} + {{ $player->latestBan->ends_at->toFormattedDateString() }} +
+
+ {{ $players->links(data: ['scrollTo' => false]) }} +
diff --git a/resources/views/pages/lists/banned.blade.php b/resources/views/pages/lists/banned.blade.php new file mode 100644 index 00000000..db346b45 --- /dev/null +++ b/resources/views/pages/lists/banned.blade.php @@ -0,0 +1,7 @@ +@extends('layouts.app') +@section('title', 'Banned Players') +@section('description', 'Banned Halo Infinite Players') + +@section('content') + +@endsection diff --git a/resources/views/partials/player/ban-header.blade.php b/resources/views/partials/player/ban-header.blade.php index 940b5b38..9191750c 100644 --- a/resources/views/partials/player/ban-header.blade.php +++ b/resources/views/partials/player/ban-header.blade.php @@ -8,7 +8,7 @@ @if (! $ban->is_expired)

- Days remaining: {{ number_format($ban->ends_at->diffInDays(absolute: true)) }}, for '{{ $ban->type }}', on scope: '{{ $ban->scope }}' + Days remaining: {{ $ban->days_remaining }}, for '{{ $ban->type }}', on scope: '{{ $ban->scope }}'

@endif diff --git a/routes/web.php b/routes/web.php index 08ec38d3..0220a629 100644 --- a/routes/web.php +++ b/routes/web.php @@ -6,6 +6,7 @@ use App\Http\Controllers\HcsController; use App\Http\Controllers\HomeController; use App\Http\Controllers\LeaderboardController; +use App\Http\Controllers\ListController; use App\Http\Controllers\OverviewController; use App\Http\Controllers\PlayerController; use App\Http\Controllers\PlaylistController; @@ -77,6 +78,9 @@ Route::get('/auth/google/callback', [GoogleController::class, 'callback'])->name('googleCallback'); Route::post('/auth/logout', [BaseAuthController::class, 'logout'])->name('logout'); +// Lists +Route::get('/lists/banned', [ListController::class, 'banned'])->name('bannedList'); + // Home Route::get('/about', [HomeController::class, 'about'])->name('about'); Route::get('/legal', [HomeController::class, 'legal'])->name('legal'); diff --git a/tests/Feature/Forms/BannedPlayerTable/ValidBannedPlayersTest.php b/tests/Feature/Forms/BannedPlayerTable/ValidBannedPlayersTest.php new file mode 100644 index 00000000..1a6c0616 --- /dev/null +++ b/tests/Feature/Forms/BannedPlayerTable/ValidBannedPlayersTest.php @@ -0,0 +1,29 @@ +has(PlayerBan::factory(), 'latestBan') + ->createOne([ + 'is_cheater' => true, + ]); + + // Act & Assert + Livewire::test(BannedPlayerTable::class) + ->assertViewHas('players') + ->assertSee($player->gamertag); + } +} diff --git a/tests/Feature/Forms/OverviewsTable/ValidOverviewsListingTest.php b/tests/Feature/Forms/OverviewsTable/ValidOverviewsListingTest.php index 9f345802..92077123 100644 --- a/tests/Feature/Forms/OverviewsTable/ValidOverviewsListingTest.php +++ b/tests/Feature/Forms/OverviewsTable/ValidOverviewsListingTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Feature\Forms\OverviewsTable; +namespace Tests\Feature\Forms\OverviewsTable; use App\Livewire\OverviewsTable; use App\Models\Overview; diff --git a/tests/Feature/Forms/PlayerBanCard/ValidPlayerBanCheckTest.php b/tests/Feature/Forms/PlayerBanCard/ValidPlayerBanCheckTest.php index 14d60e96..666dea93 100644 --- a/tests/Feature/Forms/PlayerBanCard/ValidPlayerBanCheckTest.php +++ b/tests/Feature/Forms/PlayerBanCard/ValidPlayerBanCheckTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Feature\Forms\PlayerBanCard; +namespace Tests\Feature\Forms\PlayerBanCard; use App\Livewire\PlayerBanCard; use App\Models\Player; diff --git a/tests/Feature/Pages/ListsPageTest.php b/tests/Feature/Pages/ListsPageTest.php new file mode 100644 index 00000000..e4101fc7 --- /dev/null +++ b/tests/Feature/Pages/ListsPageTest.php @@ -0,0 +1,20 @@ +get('/lists/banned'); + + // Assert + $response->assertStatus(Response::HTTP_OK); + } +}