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
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Author extends Model
{
protected $fillable = [
'name',
'slug',
'bio',
];
/**
* The books that belong to the author.
*/
public function books()
{
return $this->belongsToMany(Book::class, 'author_book')->withTimestamps();
}
}
+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);
}
}
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class SummaryReport extends Model
{
protected $fillable = [
'user_id',
'book_id',
'summary_id',
'reason',
'details',
'status',
];
public function user()
{
return $this->belongsTo(User::class);
}
public function book()
{
return $this->belongsTo(Book::class);
}
public function summary()
{
return $this->belongsTo(Summary::class);
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class SummaryRequest extends Model
{
protected $fillable = [
'user_id',
'gutenberg_id',
'title',
'notes',
'status',
];
public function user()
{
return $this->belongsTo(User::class);
}
}
+31
View File
@@ -0,0 +1,31 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class SummaryReview extends Model
{
protected $fillable = [
'user_id',
'book_id',
'summary_id',
'rating',
'comment',
];
public function user()
{
return $this->belongsTo(User::class);
}
public function book()
{
return $this->belongsTo(Book::class);
}
public function summary()
{
return $this->belongsTo(Summary::class);
}
}
+16
View File
@@ -45,4 +45,20 @@ class User extends Authenticatable
'password' => 'hashed',
];
}
/**
* Books saved by the user in their readlist.
*/
public function readlistBooks()
{
return $this->belongsToMany(Book::class, 'readlist_items')->withTimestamps();
}
/**
* Reviews authored by the user.
*/
public function reviews()
{
return $this->hasMany(SummaryReview::class);
}
}