A lot of things.

This commit is contained in:
2026-06-08 16:25:52 +02:00
parent 6f6d6b9b84
commit f529f74823
94 changed files with 9178 additions and 107 deletions

View File

@@ -5,10 +5,12 @@ namespace App\Livewire;
use App\Models\Author;
use App\Models\Entry;
use App\Models\Game;
use App\Models\Genre;
use App\Models\Language;
use App\Models\Modification;
use App\Models\Platform;
use App\Models\Status;
use Livewire\Attributes\Url;
use Livewire\Component;
use Livewire\WithPagination;
@@ -20,18 +22,21 @@ class Database extends Component
* entry_title search
* @var string
*/
#[Url(as: 's',except: '')]
public string $search = '';
/**
* type filter.
* @var array
*/
#[Url(except:[])]
public array $types = [];
/**
* Games IDs filter.
* @var array
*/
#[Url(except:[])]
public array $games = [];
/**
@@ -44,24 +49,35 @@ class Database extends Component
* Platform IDs filter.
* @var array
*/
#[Url(except:[])]
public array $platforms = [];
/**
* Genre IDs filter.
* @var array
*/
#[Url(except:[])]
public array $genres = [];
/**
* Status IDs filter.
* @var array
*/
#[Url(except:[])]
public array $statuses = [];
/**
* Authors IDs filter.
* @var array
*/
#[Url(except:[])]
public array $authors = [];
/**
* Authors mode and/or.
* @var string
*/
#[Url(except:'or')]
public string $authorsMode = 'or';
/**
@@ -74,36 +90,42 @@ class Database extends Component
* Languages IDs filter.
* @var array
*/
#[Url(except:[])]
public array $languages = [];
/**
* Languages mode and/or
* @var string
*/
#[Url(except:'or')]
public string $languagesMode = 'or';
/**
* Modifications IDs filter.
* @var array
*/
#[Url(except:[])]
public array $modifications = [];
/**
* Modifications mode and/or.
* @var string
*/
#[Url(except:'or')]
public string $modificationsMode = 'or';
/**
* Sort by field.
* @var string
*/
#[Url(as: 'sort',except: 'created_at')]
public string $sortBy = 'created_at';
/**
* asc/desc
* @var string
*/
#[Url(as: 'dir',except: 'desc')]
public string $sortDir = 'desc';
/**
@@ -134,6 +156,7 @@ class Database extends Component
public function updatedTypes(): void { $this->resetPage(); $this->dispatch('filters-updated'); }
public function updatedGames(): void { $this->resetPage(); $this->dispatch('filters-updated'); }
public function updatedPlatforms(): void { $this->resetPage(); $this->dispatch('filters-updated'); }
public function updatedGenres(): void { $this->resetPage(); $this->dispatch('filters-updated'); }
public function updatedStatuses(): void { $this->resetPage(); $this->dispatch('filters-updated'); }
public function updatedAuthors(): void { $this->resetPage(); $this->dispatch('filters-updated'); }
public function updatedAuthorsMode(): void { $this->resetPage(); $this->dispatch('filters-updated'); }
@@ -145,7 +168,7 @@ class Database extends Component
public function clearFilters(): void
{
$this->reset([
'search', 'types', 'platforms', 'statuses', 'authors', 'authorsMode', 'languages', 'languagesMode', 'modifications', 'modificationsMode'
'search', 'types', 'platforms', 'genres', 'statuses', 'authors', 'authorsMode', 'languages', 'languagesMode', 'modifications', 'modificationsMode'
]);
$this->resetPage();
}
@@ -165,7 +188,7 @@ class Database extends Component
private function buildQuery()
{
$query = Entry::query()->published()->with([
'game.platform', 'status', 'authors', 'languages'
'game.platform', 'game.genre', 'status', 'authors', 'languages'
]);
if( $this->search ) {
@@ -186,6 +209,12 @@ class Database extends Component
});
}
if( $this->genres ) {
$query->where(function($q) {
$q->whereHas('game', fn($q2) => $q2->whereIn('genre_id', $this->genres) );
});
}
if( $this->games ){
$query->whereIn('game_id', $this->games);
}
@@ -233,6 +262,7 @@ class Database extends Component
'entries' => $this->buildQuery()->paginate(self::PAGINATION),
'allGames' => Game::orderBy('name')->get(),
'allPlatforms' => Platform::orderBy('name')->get(),
'allGenres' => Genre::orderBy('name')->get(),
'allStatuses' => Status::orderBy('name')->get(),
'allAuthors' => Author::orderBy('name')->get(),
'allLanguages' => Language::orderBy('name')->get(),

View File

@@ -14,7 +14,7 @@ class XfUserSelector extends Component
public ?int $selected = null;
public ?string $selectedUsername = null;
public function mount( ?int $initialUserId ){
public function mount( ?int $initialUserId = null ){
if( $initialUserId ){
$user = DB::connection('xenforo')->table('user')->where('user_id', $initialUserId)->first();
if( $user ){