-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Banned Player Table (Undocumented) (#1559)
* feat: add "Banned" table * build: add psr violation check * chore: fix psr mismatch * test: add tests for banned players * fix: add player-ban mock * test: add latestBan seed
- Loading branch information
1 parent
b783f31
commit f4fff43
Showing
13 changed files
with
193 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Artesaos\SEOTools\Facades\SEOTools; | ||
use Illuminate\View\View; | ||
|
||
class ListController extends Controller | ||
{ | ||
public function banned(): View | ||
{ | ||
SEOTools::setTitle(e('Banned Players')); | ||
SEOTools::setDescription(e('Halo Infinite - Banned Players')); | ||
|
||
return view('pages.lists.banned'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace App\Livewire; | ||
|
||
use App\Models\Player; | ||
use Illuminate\View\View; | ||
use Livewire\Component; | ||
use Livewire\WithPagination; | ||
|
||
class BannedPlayerTable extends Component | ||
{ | ||
use WithPagination; | ||
|
||
public function paginationView(): string | ||
{ | ||
return 'pagination::bulma'; | ||
} | ||
|
||
public function render(): View | ||
{ | ||
$players = Player::query() | ||
->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, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
/** @var App\Models\Player[] $players */ | ||
?> | ||
<div> | ||
<h1 class="title">Banned Halo Infinite Players</h1> | ||
<h2 class="subtitle">A collection of banned players that Leaf knows about.</h2> | ||
<div class="table-container"> | ||
<table class="table is-striped is-narrow is-hoverable is-fullwidth"> | ||
<thead> | ||
<tr> | ||
<th>Gamertag</th> | ||
<th>Reason</th> | ||
<th>Scope</th> | ||
<th>Expiration</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach ($players as $player) | ||
<tr> | ||
<td> | ||
<article class="media"> | ||
<figure class="media-left"> | ||
<p class="image is-32x32"> | ||
<img src="{{ $player->emblem_url }}" alt="emblem"> | ||
</p> | ||
</figure> | ||
<div class="media-content"> | ||
<div class="content" style="white-space: nowrap"> | ||
@include('partials.links.player', ['player' => $player]) | ||
@if ($player->is_donator) | ||
<span class="tag is-success" data-tooltip="Donated via BuyMeACoffee" style="border-bottom: 0;"> | ||
<i class="fas fa-leaf"></i> | ||
</span> | ||
@endif | ||
@if ($player->is_cheater) | ||
<span class="tag is-danger">Cheater</span> | ||
@endif | ||
@if ($player->is_botfarmer) | ||
<span class="tag is-info">Farmer</span> | ||
@endif | ||
</div> | ||
</div> | ||
</article> | ||
</td> | ||
<td class="has-tooltip-arrow has-tooltip-text-left-mobile" | ||
data-tooltip="{{ $player->latestBan->days_remaining }} days remaining" | ||
> | ||
{{ $player->latestBan->short_message }} | ||
</td> | ||
<td>{{ $player->latestBan->scope }}, {{ $player->latestBan->type }}</td> | ||
<td> | ||
{{ $player->latestBan->ends_at->toFormattedDateString() }} | ||
</td> | ||
</tr> | ||
@endforeach | ||
</tbody> | ||
</table> | ||
</div> | ||
{{ $players->links(data: ['scrollTo' => false]) }} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@extends('layouts.app') | ||
@section('title', 'Banned Players') | ||
@section('description', 'Banned Halo Infinite Players') | ||
|
||
@section('content') | ||
<livewire:banned-player-table /> | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
tests/Feature/Forms/BannedPlayerTable/ValidBannedPlayersTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Feature\Forms\BannedPlayerTable; | ||
|
||
use App\Livewire\BannedPlayerTable; | ||
use App\Models\Player; | ||
use App\Models\PlayerBan; | ||
use Livewire\Livewire; | ||
use Tests\TestCase; | ||
|
||
class ValidBannedPlayersTest extends TestCase | ||
{ | ||
public function test_valid_loading_of_banned_players(): void | ||
{ | ||
// Arrange | ||
$player = Player::factory() | ||
->has(PlayerBan::factory(), 'latestBan') | ||
->createOne([ | ||
'is_cheater' => true, | ||
]); | ||
|
||
// Act & Assert | ||
Livewire::test(BannedPlayerTable::class) | ||
->assertViewHas('players') | ||
->assertSee($player->gamertag); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Feature\Pages; | ||
|
||
use Symfony\Component\HttpFoundation\Response; | ||
use Tests\TestCase; | ||
|
||
class ListsPageTest extends TestCase | ||
{ | ||
public function test_example_banned_players(): void | ||
{ | ||
// Arrange & Act | ||
$response = $this->get('/lists/banned'); | ||
|
||
// Assert | ||
$response->assertStatus(Response::HTTP_OK); | ||
} | ||
} |