bookinventory/app/Models/Author.php
Tyler 9daa8a6667
All checks were successful
continuous-integration/drone/push Build is passing
Rollback PHP to 7.4
2020-12-27 02:53:41 -05:00

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',
]
]
],
]
];
}