search refactor3

This commit is contained in:
merdan 2023-08-15 13:29:51 +05:00
parent 3b7532429c
commit 022f6027cc
2 changed files with 15 additions and 4 deletions

View File

@ -527,10 +527,8 @@ class ProductRepository extends PRepository
$qb = app(ProductFlatRepository::class)->getModel()::search(implode(' OR ', $queries))
->take($perPage)
// ->query(fn ($query) =>)
// ->where('status', 1)
// ->where('visible_individually', 1)
->where('status', 1)
->where('visible_individually', 1)
->where('channel', $channel)
->where('locale', $locale)
->orderBy('product_id', 'desc');

View File

@ -50,6 +50,19 @@ class ProductFlat extends Model implements ProductFlatContract
return 'products_index';
}
public function toSearchableArray():array
{
return [
'id' => $this->id,
'locale' => $this->locale,
'channel' => $this->channel,
'name' => $this->name,
'meta_keywords' => $this->meta_keywords,
'status' => $this->status,
'visible_individually'=> $this->visible_individually,
'product_id' => $this->product_id
];
}
/**
* Get an attribute from the model.
*