How can I add a custom facet?
You can add a custom facet by extending the listing document.
For example you can add a Stock Status facet:
\Aero\Search\Elastic\Documents\ListingDocument::add('string-facets', function ($document) {
$stock = $document->getModel()->availableStock() > 0;
return [
\Aero\Search\Elastic\Facet::create('stock', 'Stock Status', (int) $stock, $stock ? 'In stock' : 'Out of stock'),
];
});
You must run php artisan aero:search:reindex --type=listing for these document changes to be applied to existing listings.
And then register it so that it appears on the listings page as a facet:
\Aero\Search\FacetSettings::registerFacet('stock', 'Stock Status');