Closed renatosistemasvc closed 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?
how it fix ?
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:
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
Does anyone have any idea why the toSearchableArray does not work?