some progress
This commit is contained in:
@@ -16,6 +16,14 @@ class Book extends Model
|
||||
'category_id',
|
||||
];
|
||||
|
||||
/**
|
||||
* Use slug for route model binding and URL generation.
|
||||
*/
|
||||
public function getRouteKeyName(): string
|
||||
{
|
||||
return 'slug';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category that owns the book.
|
||||
*/
|
||||
@@ -31,4 +39,36 @@ class Book extends Model
|
||||
{
|
||||
return $this->hasOne(Summary::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* The authors that belong to the book.
|
||||
*/
|
||||
public function authors()
|
||||
{
|
||||
return $this->belongsToMany(Author::class, 'author_book')->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* Users who saved this book to their readlist.
|
||||
*/
|
||||
public function savedByUsers()
|
||||
{
|
||||
return $this->belongsToMany(User::class, 'readlist_items')->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports submitted for this book's summary.
|
||||
*/
|
||||
public function reports()
|
||||
{
|
||||
return $this->hasMany(SummaryReport::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reviews left by users for this book's summary.
|
||||
*/
|
||||
public function reviews()
|
||||
{
|
||||
return $this->hasMany(SummaryReview::class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user