bookinventory/app/Models/Book.php
Tyler a1ac81a73a
All checks were successful
continuous-integration/drone/push Build is passing
Add attachments, more pages
2020-12-26 19:34:07 -05:00

47 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use App\Services\Search\BookConfigurator;
use Bnb\Laravel\Attachments\HasAttachment;
use Illuminate\Database\Eloquent\Model;
use ScoutElastic\Searchable;
class Book extends Model {
use Searchable, HasAttachment;
protected $indexConfigurator = BookConfigurator::class;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'location_id', 'barcode', 'name',
];
public function authors() {
return $this->belongsToMany(Author::class, 'book_authors');
}
public function location() {
return $this->belongsTo(Location::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',
]
]
],
]
];
}