fix: remove non-visible article from research results
This commit is contained in:
@@ -19,7 +19,7 @@ class Articles
|
|||||||
|
|
||||||
public static function autocomplete($str)
|
public static function autocomplete($str)
|
||||||
{
|
{
|
||||||
$data = Article::byAutocomplete($str)->orderBy('name')->limit(20)->pluck('name', 'id');
|
$data = Article::byAutocomplete($str)->visible()->orderBy('name')->limit(20)->pluck('name', 'id');
|
||||||
$export = [];
|
$export = [];
|
||||||
foreach ($data as $key => $name) {
|
foreach ($data as $key => $name) {
|
||||||
$export[] = ['value' => $key, 'text' => $name];
|
$export[] = ['value' => $key, 'text' => $name];
|
||||||
|
|||||||
@@ -8,8 +8,14 @@ class Searches
|
|||||||
{
|
{
|
||||||
public static function search($options)
|
public static function search($options)
|
||||||
{
|
{
|
||||||
|
// Get article IDs from Scout search
|
||||||
|
$searchResults = Article::search($options['search_name'])->get()->pluck('id');
|
||||||
|
|
||||||
|
// Filter to only include visible articles
|
||||||
|
$visibleArticleIds = Article::whereIn('id', $searchResults)->visible()->pluck('id');
|
||||||
|
|
||||||
return collect(Articles::getArticlesToSell([
|
return collect(Articles::getArticlesToSell([
|
||||||
'ids' => Article::search($options['search_name'])->get()->pluck('id'),
|
'ids' => $visibleArticleIds,
|
||||||
]))->sortBy('searchOrder')->toArray();
|
]))->sortBy('searchOrder')->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user