Fixed several bugs
This commit is contained in:
@@ -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 )
|
||||
|
||||
@@ -21,6 +21,7 @@ class EntrySelector extends Component
|
||||
if( $entry ) {
|
||||
$this->selectedEntryId = $oldEntryId;
|
||||
$this->entryName = $entry->complete_title ?? $entry->title;
|
||||
$this->search = $entry->complete_title ?? $entry->title;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user