Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Explorer Laravel Package

jeroen-g/explorer

Laravel-friendly wrapper for Explorer, a lightweight full-text search engine. Index and search your Eloquent models with simple configuration, fast queries, and flexible ranking/filters. Ideal for adding on-site search without running Elasticsearch or Algolia.

View on GitHub
Deep Wiki
Context7

Preparing data

Text analysis is perfect when you want to alter how Elasticsearch deals with a query, or with the data when it is being indexed. However, sometimes you do not necessarily want to meddle with analyzer, but rather just make a quick change to the data before it is indexed, perhaps conditionally.

For this, Explorer gives you the ability to 'prepare' your searchable data. To use this you will need to implement the JeroenG\Explorer\Application\BePrepared interface on your model and add the prepare($data) function. The data that is passed to the prepare function is what Laravel Scout generates in the toSearchableArray() method.

The prepared data might be very simple:

public function prepare(array $searchable): array
{
    $searchable['name'] = ucfirst($searchable['name']);

    return $searchable;
}

Or you could use something like Laravel's pipelines to do much more complex stuff:

public function prepare(array $searchable): array
{
    $searchable['content'] = (new Illuminate\Pipeline\Pipeline())
                ->send($searchable['content'])
                ->through([
                    App\Formatters\ConvertMarkdown::class,              
                    App\Formatters\StripTags::class,
                    App\Formatters\EncodeEmoji::class,
                ])
                ->thenReturn();

    return $searchable;
}
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation
uri-template/tests