Initial
This commit is contained in:
21
app/Models/Author.php
Normal file
21
app/Models/Author.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Author extends Model
|
||||
{
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'pathword',
|
||||
];
|
||||
|
||||
public function comics(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Comic::class);
|
||||
}
|
||||
|
||||
}
|
||||
30
app/Models/Chapter.php
Normal file
30
app/Models/Chapter.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Chapter extends Model
|
||||
{
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'chapter_uuid' => 'string',
|
||||
'upstream_created_at' => 'date',
|
||||
'metadata' => 'json',
|
||||
];
|
||||
}
|
||||
|
||||
public function comic(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Comic::class);
|
||||
}
|
||||
|
||||
public function images(): HasMany
|
||||
{
|
||||
return $this->hasMany(Image::class);
|
||||
}
|
||||
|
||||
}
|
||||
31
app/Models/Comic.php
Normal file
31
app/Models/Comic.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Comic extends Model
|
||||
{
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'uuid' => 'string',
|
||||
'alias' => 'array',
|
||||
'upstream_updated_at' => 'datetime:Y-m-d',
|
||||
'metadata' => 'json',
|
||||
];
|
||||
}
|
||||
|
||||
public function authors(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Author::class);
|
||||
}
|
||||
|
||||
public function chapters(): HasMany
|
||||
{
|
||||
return $this->hasMany(Chapter::class);
|
||||
}
|
||||
|
||||
}
|
||||
36
app/Models/Image.php
Normal file
36
app/Models/Image.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Image extends Model
|
||||
{
|
||||
|
||||
protected $fillable = [
|
||||
'comic_id',
|
||||
'chapter_id',
|
||||
'order',
|
||||
'url',
|
||||
'metadata',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'metadata' => 'json',
|
||||
];
|
||||
}
|
||||
|
||||
public function chapter(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Chapter::class);
|
||||
}
|
||||
|
||||
public function comic(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Comic::class);
|
||||
}
|
||||
|
||||
}
|
||||
26
app/Models/ReadingHistory.php
Normal file
26
app/Models/ReadingHistory.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class ReadingHistory extends Model
|
||||
{
|
||||
|
||||
public function comic(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Comic::class);
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function chapter(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Chapter::class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,14 +2,17 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Database\Factories\UserFactory;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Authenticatable
|
||||
class User extends Authenticatable implements MustVerifyEmail
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
@@ -45,4 +48,15 @@ class User extends Authenticatable
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
public function favourites(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Comic::class, 'user_favourite')->withTimestamps();
|
||||
}
|
||||
|
||||
public function readingHistories(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Comic::class, 'reading_histories')->withTimestamps();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user