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

Get relationship does not work #220

Closed renatosistemasvc closed 5 years ago

renatosistemasvc commented 5 years ago

I'm using teamtnt / laravel-scout-tntsearch-driver I followed the documentation example and did not try to capture my model's relationships.

How can I search the products and the relation "One To Many" of marks?

public function toSearchableArray()
{

   return [
       'id' => $this->id,
       'name' => $this->name,
       'mark' => $this->mark['name']
   ];

}

public function mark()
{
  return $this->belongsTo('App\Models\Marca');
}

search

Product::search($filter)->get()->toArray();

When I run, I do not have the marks.