2020-12-21 07:09:34 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
2020-12-26 10:46:23 +00:00
|
|
|
use App\Services\Search\BookConfigurator;
|
2020-12-27 00:34:07 +00:00
|
|
|
use Bnb\Laravel\Attachments\HasAttachment;
|
2020-12-26 10:46:23 +00:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use ScoutElastic\Searchable;
|
2020-12-21 07:09:34 +00:00
|
|
|
|
2020-12-26 10:46:23 +00:00
|
|
|
class Book extends Model {
|
|
|
|
|
2020-12-27 00:34:07 +00:00
|
|
|
use Searchable, HasAttachment;
|
2020-12-26 10:46:23 +00:00
|
|
|
|
|
|
|
protected $indexConfigurator = BookConfigurator::class;
|
2020-12-21 07:09:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $fillable = [
|
2020-12-26 10:46:23 +00:00
|
|
|
'location_id', 'barcode', 'name',
|
2020-12-21 07:09:34 +00:00
|
|
|
];
|
|
|
|
|
2020-12-27 09:29:52 +00:00
|
|
|
protected $casts = [
|
|
|
|
'published_date' => 'datetime:Y-m-d'
|
|
|
|
];
|
|
|
|
|
2020-12-26 10:46:23 +00:00
|
|
|
public function authors() {
|
|
|
|
return $this->belongsToMany(Author::class, 'book_authors');
|
2020-12-21 07:09:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function location() {
|
|
|
|
return $this->belongsTo(Location::class);
|
|
|
|
}
|
2020-12-26 10:46:23 +00:00
|
|
|
|
|
|
|
protected $mapping = [
|
|
|
|
'properties' => [
|
|
|
|
'name' => [
|
|
|
|
'type' => 'text',
|
|
|
|
'fields' => [
|
|
|
|
'raw' => [
|
|
|
|
'type' => 'keyword',
|
|
|
|
]
|
|
|
|
]
|
|
|
|
],
|
2020-12-27 09:29:52 +00:00
|
|
|
'description' => [
|
|
|
|
'type' => 'text',
|
|
|
|
'fields' => [
|
|
|
|
'raw' => [
|
|
|
|
'type' => 'keyword',
|
|
|
|
]
|
|
|
|
]
|
|
|
|
],
|
|
|
|
'published_date' => [
|
|
|
|
'type' => 'date',
|
|
|
|
'format' => 'yyyy-MM-dd'
|
|
|
|
]
|
2020-12-26 10:46:23 +00:00
|
|
|
]
|
|
|
|
];
|
2020-12-21 07:09:34 +00:00
|
|
|
}
|