teamtnt / laravel-scout-tntsearch-driver

Driver for Laravel Scout search package based on https://github.com/teamtnt/tntsearch
MIT License
1.1k stars 144 forks source link

the toSearchableArray () method does not work #190

Closed renatosistemasvc closed 6 years ago

renatosistemasvc commented 6 years ago

Laravel 5.6

I'm doing a test adding an attribute using toSearchableArray () but it does not seem to work.

in my model my method is like this:

public function toSearchableArray()
{
        $array = $this->toArray();
        $array['test'] = 'testing';
        return $array;
}

later I run the command on my terminal:

php artisan scout:import App\\Models\\Produto

I also tried

php artisan tntsearch:import App\\Models\\Produto

And in my controller I search as follows:

Produto::search('prod')->get()->toArray();

In my result the test variable does not appear

 0 => array:22 [▼
    "id" => 2
    "nome" => "prod 2"
    "codigo" => "10000089CE"
    "tipo" => null
    "created_at" => "2018-08-28 00:28:58"
    "updated_at" => "2018-08-28 00:28:58"
    "deleted_at" => null
  ]

Does anyone have any idea why the toSearchableArray does not work?

jalallinux commented 3 years ago

how it fix ?