bookinventory/app/Models/Author.php

42 lines
946 B
PHP
Raw Normal View History

2020-12-21 07:09:34 +00:00
<?php
namespace App\Models;
2020-12-27 07:53:41 +00:00
use App\Services\Search\AuthorConfigurator;
2020-12-26 10:46:23 +00:00
use Illuminate\Database\Eloquent\Model;
2020-12-27 07:53:41 +00:00
use ScoutElastic\Searchable;
2020-12-21 07:09:34 +00:00
2020-12-26 10:46:23 +00:00
class Author extends Model {
2020-12-21 07:09:34 +00:00
2020-12-27 07:53:41 +00:00
use Searchable;
protected $indexConfigurator = AuthorConfigurator::class;
2020-12-21 07:09:34 +00:00
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
];
public function books() {
return $this->belongsToMany(Book::class);
}
2020-12-27 07:53:41 +00:00
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',
]
]
],
]
];
2020-12-21 07:09:34 +00:00
}