42 lines
946 B
PHP
42 lines
946 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Services\Search\AuthorConfigurator;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use ScoutElastic\Searchable;
|
|
|
|
class Author extends Model {
|
|
|
|
use Searchable;
|
|
|
|
protected $indexConfigurator = AuthorConfigurator::class;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
];
|
|
|
|
public function books() {
|
|
return $this->belongsToMany(Book::class);
|
|
}
|
|
|
|
protected $mapping = [
|
|
'properties' => [
|
|
'name' => [
|
|
'type' => 'text',
|
|
// Also you can configure multi-fields, more details you can find here https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html
|
|
'fields' => [
|
|
'raw' => [
|
|
'type' => 'keyword',
|
|
]
|
|
]
|
|
],
|
|
]
|
|
];
|
|
}
|