some progress

This commit is contained in:
2025-09-20 16:47:41 +03:00
parent e650f3c1b2
commit 2228469bcb
65 changed files with 3382 additions and 311 deletions
+40
View File
@@ -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);
}
}