mirror of
https://github.com/HtetPhone/MangaDex.git
synced 2025-02-20 11:23:19 +08:00
select box onchange-submit and go to the specific chapter
This commit is contained in:
parent
d63979b5e3
commit
27cd37bcfe
@ -38,7 +38,7 @@ class PageController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function chapter(Manga $manga, Chapter $chapter)
|
||||
public function chapter(Manga $manga,Chapter $chapter)
|
||||
{
|
||||
$firstChapter = $manga->chapters()->orderBy('chapter_no', 'asc')->first();
|
||||
$lastChapter = $manga->chapters()->latest('chapter_no')->first();
|
||||
@ -49,4 +49,10 @@ class PageController extends Controller
|
||||
'lastChapter' => $lastChapter
|
||||
]);
|
||||
}
|
||||
|
||||
public function select(Manga $manga, Request $request)
|
||||
{
|
||||
// dd($request);
|
||||
return redirect()->route('page.chapter', [$manga, $request->chapter_no]);
|
||||
}
|
||||
}
|
||||
|
@ -1 +1,6 @@
|
||||
import './bootstrap';
|
||||
|
||||
// let selectChapter = document.querySelector('#selectChapter');
|
||||
// selectChapter.addEventListener('change', function() {
|
||||
// this.submit();
|
||||
// });
|
||||
|
@ -1,8 +1,12 @@
|
||||
<div class="col-4">
|
||||
<select name="" id="" class="form-select">
|
||||
@foreach ($manga->chapters()->latest('id')->get() as $chap)
|
||||
<option value="{{ $chap->id }}" {{ $chap->id == $chapter->id ? 'selected' : '' }}>
|
||||
Chapter {{ $chap->chapter_no }} - {{ $chap->title ?? '' }} </option>
|
||||
<form action="{{route('select.chapter', [$manga->slug])}}" method="post" id="selectChapter" onchange="this.submit();">
|
||||
@csrf
|
||||
<select name="chapter_no" class="form-select">
|
||||
@foreach ($manga->chapters()->latest('chapter_no')->get() as $chap)
|
||||
<option value="{{ $chap->chapter_no }}" {{ $chap->chapter_no == $chapter->chapter_no ? 'selected' : '' }}>
|
||||
Chapter {{ $chap->chapter_no }} - {{ $chap->title ?? '' }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -24,6 +24,7 @@ Route::controller(PageController::class)->group(function () {
|
||||
Route::get('/', 'index')->name('page.index');
|
||||
Route::get('/MangaDex/manga/{slug}', 'manga')->name('page.manga');
|
||||
Route::get('/manga/{manga:slug}/chapter/{chapter:chapter_no?}', 'chapter')->name('page.chapter');
|
||||
Route::post('/manga/{manga:slug}/select', 'select')->name('select.chapter');
|
||||
});
|
||||
|
||||
Auth::routes();
|
||||
|
Loading…
x
Reference in New Issue
Block a user