Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Rudy-L's avatar

Scout without angolia

Can someyone me explain the code i need, because i have always a emplty array as result.

i have make next staps:

=> composer require laravel/scout

=> php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider"

=> Model: use Laravel\Scout\Searchable;

use Searchable;

=> Config/scout: 'driver' => env('SCOUT_DRIVER', 'null'),

What about this functions? do i need this?

=> public function searchableAs() { return 'posts_index'; }

=> public function toSearchableArray() { $array = $this->toArray();

    Customize array...return $array; 
}
0 likes
6 replies
Sti3bas's avatar

@Rudy-L what do you want to achieve? null driver doesn't store any data.

Rudy-L's avatar

I have to choise, angolia or null.

/* |-------------------------------------------------------------------------- | Default Search Engine |-------------------------------------------------------------------------- | | This option controls the default search connection that gets used while | using Laravel Scout. This connection is used when syncing all models | to the search service. You should adjust this based on your needs. | | Supported: "algolia", "null" | */

'driver' => env('SCOUT_DRIVER', 'null'),
Reppair's avatar

The problem with the MySQL package is that it does not allow for indexing related models:

    public function toSearchableArray()
    {
        return [
            'bulb' => $this->bulb->title,
        ];
    }

such indexing of the related model's translatable (JSON column) is not possible yet. What I am looking for is something simpler the TNTSearch but still having a search index that allows me to add extra fields to it.

Rudy-L's avatar

thx a lot.

mysql is what i need

Nakov's avatar

@rudy, is it your answer the best answer or did @sti3bas helped you with the list he provided? :)

2 likes

Please or to participate in this conversation.