46 lines
790 B
PHP
46 lines
790 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Cviebrock\EloquentSluggable\Sluggable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Book extends Model
|
|
{
|
|
use Sluggable;
|
|
|
|
public function getRouteKeyName()
|
|
{
|
|
return 'slug';
|
|
}
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*/
|
|
protected $fillable = [
|
|
'user_id', 'photo', 'name', 'description',
|
|
];
|
|
|
|
/**
|
|
* Return the sluggable configuration array for this model.
|
|
*/
|
|
public function sluggable()
|
|
{
|
|
return [
|
|
'slug' => [
|
|
'source' => 'name'
|
|
]
|
|
];
|
|
}
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function comments()
|
|
{
|
|
return $this->hasMany(Comment::class);
|
|
}
|
|
}
|