F
Filament6mo ago
Sydd

global search sort results

Please, i looking for solution sort global search results by column date_at descending, try this, but dont work:
public static function getGlobalSearchResults(string $search): Collection
{
return parent::getGlobalSearchResults($search)->sortByDesc('date_at');
}
public static function getGlobalSearchResults(string $search): Collection
{
return parent::getGlobalSearchResults($search)->sortByDesc('date_at');
}
Solution:
You probably need to order the query as opposed to the collection? 🤔 ```php public static function getGlobalSearchEloquentQuery(): Builder {...
Jump to solution
2 Replies
Solution
dissto
dissto6mo ago
You probably need to order the query as opposed to the collection? 🤔
public static function getGlobalSearchEloquentQuery(): Builder
{
return parent::getGlobalSearchEloquentQuery()->orderBy('date_at', 'desc');
}
public static function getGlobalSearchEloquentQuery(): Builder
{
return parent::getGlobalSearchEloquentQuery()->orderBy('date_at', 'desc');
}
See: https://filamentphp.com/docs/3.x/panels/resources/global-search#adding-extra-details-to-global-search-results
Sydd
SyddOP6mo ago
Great !!! thank you !!!
Want results from more Discord servers?
Add your server