0.1.1
This commit is contained in:
@@ -64,8 +64,8 @@ class ComicController extends Controller
|
||||
public function postFavourite(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
// Get pathname to comic_id
|
||||
$comic = Comic::where('pathword', $request->pathword)->firstOrFail();
|
||||
// Get pathname to comic_id, if metadata is null, also do fetching
|
||||
$comic = Comic::where('pathword', $request->pathword)->whereNotNull('metadata')->firstOrFail();
|
||||
} catch (ModelNotFoundException $e) {
|
||||
// Fetch from remote
|
||||
$remoteComic = $this->copyManga->comic($request->pathword);
|
||||
@@ -345,9 +345,13 @@ class ComicController extends Controller
|
||||
// Update history
|
||||
$request->user()->readingHistories()->attach($chapterObj->id, ['comic_id' => $comicObj->id]);
|
||||
|
||||
// Get chapters from DB
|
||||
$chapters = $comicObj->chapters()->where('metadata->group_path_word', $chapter['chapter']['group_path_word'])->orderBy('order')->get(['name', 'chapter_uuid']);
|
||||
|
||||
return Inertia::render('Comic/Read', [
|
||||
'comic' => $this->scToZh($comic),
|
||||
'chapter' => $this->scToZh($chapter),
|
||||
'chapters' => $this->scToZh($chapters),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -385,6 +389,13 @@ class ComicController extends Controller
|
||||
return redirect()->route('comics.histories');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove histories for specified comic
|
||||
*
|
||||
* @param Request $request
|
||||
* @param string $pathword
|
||||
* @return Response
|
||||
*/
|
||||
public function destroyHistory(Request $request, string $pathword): Response
|
||||
{
|
||||
$comicId = Comic::where('pathword', $pathword)->firstOrFail(['id'])->id;
|
||||
@@ -399,6 +410,12 @@ class ComicController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove duplicated records
|
||||
*
|
||||
* @param Request $request
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function destroyHistories(Request $request): RedirectResponse
|
||||
{
|
||||
$result = $request->user()->cleanUpReadingHistories();
|
||||
|
||||
Reference in New Issue
Block a user