Fixed several bugs

This commit is contained in:
2026-06-29 19:24:35 +02:00
parent 73844b6db0
commit c76bf45904
8 changed files with 83 additions and 5 deletions

View File

@@ -175,6 +175,7 @@ class Database extends Component
public const array SORT_OPTIONS = [
'created_at' => 'Date added',
'release_date' => 'Release date',
'total_downloads' => 'Total downloads',
'title' => 'Title'
];
@@ -236,7 +237,7 @@ class Database extends Component
{
$query = Entry::query()->published()->with([
'game.platform', 'game.genre', 'status', 'authors', 'languages', 'level', 'systems', 'categories', 'modifications'
]);
])->withSum('files', 'download_count');
if( $this->search ) {
$query->where(function($q) {
@@ -328,7 +329,13 @@ class Database extends Component
$query->where('user_id', $this->userId);
}
return $query->orderBy($this->sortBy, $this->sortDir);
$sortColumn = $this->sortBy;
if ($sortColumn === 'total_downloads') {
$sortColumn = 'files_sum_download_count';
}
return $query->orderBy($sortColumn, $this->sortDir);
}
private function searchFilter( string $modelClass, string $search )