Migration complete

This commit is contained in:
2026-06-23 19:24:38 +02:00
parent 279160c1cb
commit 64b26ef059
126 changed files with 8121 additions and 221 deletions

View File

@@ -128,7 +128,7 @@ class Database extends Component
* Categories mode and/or
* @var string
*/
#[Url(except:['or'])]
#[Url(except:'or')]
public string $categoriesMode = 'or';
/**
@@ -142,7 +142,7 @@ class Database extends Component
* Systems mode and/or
* @var string
*/
#[Url(except:['or'])]
#[Url(except:'or')]
public string $systemsMode = 'or';
/**
@@ -152,6 +152,9 @@ class Database extends Component
#[Url(except:[])]
public array $levels = [];
#[Url(except:null)]
public ?int $userId = null;
/**
* Sort by field.
* @var string
@@ -185,7 +188,6 @@ class Database extends Component
'utilities' => 'Utilities',
'documents' => 'Documents',
'lua-scripts' => 'Lua Scripts',
'tutorials' => 'Tutorials',
];
public const int PAGINATION = 30;
@@ -207,12 +209,14 @@ class Database extends Component
public function updatedSystems(): void { $this->resetPage(); $this->dispatch('filters-updated'); }
public function updatedSystemsMode(): void { $this->resetPage(); $this->dispatch('filters-updated'); }
public function updatedLevels(): void { $this->resetPage(); $this->dispatch('filters-updated'); }
public function updatedUserId(): void { $this->resetPage(); $this->dispatch('filters-updated'); }
public function clearFilters(): void
{
$this->reset([
'search', 'types', 'platforms', 'genres', 'statuses', 'authors', 'authorsMode', 'languages', 'languagesMode', 'modifications', 'modificationsMode', 'categories', 'categoriesMode', 'systems', 'systemsMode', 'levels'
'search', 'types', 'platforms', 'genres', 'statuses', 'authors', 'authorsMode', 'languages', 'languagesMode', 'modifications', 'modificationsMode', 'categories', 'categoriesMode', 'systems', 'systemsMode', 'levels', 'userId'
]);
$this->dispatch('filters-updated');
$this->resetPage();
}
@@ -320,18 +324,59 @@ class Database extends Component
}
}
if( $this->userId ){
$query->where('user_id', $this->userId);
}
return $query->orderBy($this->sortBy, $this->sortDir);
}
private function searchFilter( string $modelClass, string $search )
{
$this->dispatch('filters-updated');
if( mb_strlen( $search ) < 3 ) {
return collect();
}
return $modelClass::where('name', 'like', "%{$search}%")
->orderBy('name')
->limit(50)
->get();
}
private function searchGameFilter()
{
$search = $this->gameSearch;
$this->dispatch('filters-updated');
if( mb_strlen( $search ) < 3 ) {
return collect();
}
$collect = Game::where('name', 'like', "%{$search}%")
->orderBy('name')
->limit(50)
->get();
return $collect->map(function($item){
$item->name = $item->name . ' (' . ($item->platform?->short_name ?? $item->platform->name) . ')';
return $item;
} );
}
public function render()
{
return view('livewire.database', [
'entries' => $this->buildQuery()->paginate(self::PAGINATION),
'allGames' => Game::orderBy('name')->get(),
'allGames' => $this->searchGameFilter(),
'allPlatforms' => Platform::orderBy('name')->get(),
'allGenres' => Genre::orderBy('name')->get(),
'allStatuses' => Status::orderBy('name')->get(),
'allAuthors' => Author::orderBy('name')->get(),
'allAuthors' => $this->searchFilter(Author::class, $this->authorSearch),
'allLanguages' => Language::orderBy('name')->get(),
'allModifications' => Modification::orderBy('name')->get(),
'allCategories' => Category::orderBy('name')->get(),