mirror of
https://github.com/HtetPhone/MangaDex.git
synced 2025-02-20 11:23:19 +08:00
next previous buttons in chapter page done
This commit is contained in:
parent
0c13543c28
commit
c012735176
@ -33,11 +33,13 @@ class ChapterController extends Controller
|
||||
*/
|
||||
public function store(StoreChapterRequest $request)
|
||||
{
|
||||
// dd ($request->file('images'));
|
||||
|
||||
$formData = $request->validated();
|
||||
$formData['user_id'] = Auth::id();
|
||||
if($request->hasFile('images')) {
|
||||
foreach ($request->file('images') as $image) {
|
||||
$images[] = $image->store($request->manga_id.'OfChapter', 'public');
|
||||
foreach ($request->file('images') as $key => $image) {
|
||||
$images[] = $image->store($request->manga_id.'ChapterImages', 'public');
|
||||
}
|
||||
$formData['images'] = $images;
|
||||
}
|
||||
@ -89,3 +91,4 @@ class ChapterController extends Controller
|
||||
return view('chapter.manageChapter', compact('manga'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,14 +2,16 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Chapter;
|
||||
use App\Models\Manga;
|
||||
use App\Models\Chapter;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class PageController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
// Storage::disk('local')->put('example.txt', 'Contents');
|
||||
$mangas = Manga::latest('id')->paginate(8)->withQueryString();
|
||||
return view('index', [
|
||||
'mangas' => $mangas
|
||||
|
@ -22,8 +22,10 @@ class StoreChapterRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'min:3',
|
||||
'manga_id' => 'required|exists:mangas,id'
|
||||
'title' => 'required|min:3',
|
||||
'manga_id' => 'required|exists:mangas,id',
|
||||
'images' => 'required',
|
||||
'images.*' => 'file|mimes:png,jpg'
|
||||
];
|
||||
}
|
||||
|
||||
@ -31,7 +33,9 @@ class StoreChapterRequest extends FormRequest
|
||||
{
|
||||
return [
|
||||
'manga_id.required' => 'Please Select the Manga',
|
||||
'manga_id.exists' => 'Please Select the Manga'
|
||||
'manga_id.exists' => 'Please Select the Manga',
|
||||
'images.required' => 'Please Select Chapter images',
|
||||
// 'images.*.mimes:png,jpg' => 'Invalid Image extensions'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,15 @@ class StoreMangaRequest extends FormRequest
|
||||
return [
|
||||
'title' => 'required|min:3|max:100',
|
||||
'summary' => 'required|min:3',
|
||||
'cover' => 'required|file'
|
||||
'cover' => 'file|required|mimes:png,jpg'
|
||||
];
|
||||
}
|
||||
|
||||
//error messages
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'cover.required' => 'Please Select Cover Image'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,16 @@ class UpdateMangaRequest extends FormRequest
|
||||
{
|
||||
return [
|
||||
'title' => 'required|min:3',
|
||||
'summary' => 'required|min:3|max:2000'
|
||||
'summary' => 'required|min:3|max:2000',
|
||||
'cover' => 'file|required|mimes:png,jpg'
|
||||
];
|
||||
}
|
||||
|
||||
//error messages
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'cover.required' => 'Please Select Cover Image'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
<a title="back" href="{{ url()->previous() }}" class="btn btn-dark"> <i class="bi bi-arrow-left"></i> </a>
|
||||
<a href="{{ route('chapter.index') }}" class="btn btn-dark"> <i class="bi bi-book"></i> Chapter List</a>
|
||||
</div>
|
||||
|
||||
|
||||
<form method="POST" action="{{ route('chapter.store') }}" enctype="multipart/form-data">
|
||||
@csrf
|
||||
<div class="mb-3">
|
||||
@ -25,7 +25,7 @@
|
||||
@enderror
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="">Chapter Title <span class="text-danger">*Optinal</span></label>
|
||||
<label for="">Chapter Title</label>
|
||||
<input type="text" name="title" class="form-control">
|
||||
@error('title')
|
||||
<p class="text-danger small">{{ $message }}</p>
|
||||
@ -35,6 +35,9 @@
|
||||
<div class="mb-3">
|
||||
<label for="">Chapter Images</label>
|
||||
<input type="file" name="images[]" id="" class="form-control" multiple>
|
||||
@error('images')
|
||||
<p class="text-danger small">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-outline-dark">Create</button>
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
{{-- manga images --}}
|
||||
<div class="mb-4">
|
||||
@foreach ($chapter->images as $image)
|
||||
@foreach (array_reverse($chapter->images) as $image)
|
||||
<img src="{{ asset('storage/'.$image) }}" class="mx-auto w-50 my-0" alt="">
|
||||
@endforeach
|
||||
</div>
|
||||
@ -24,6 +24,6 @@
|
||||
@include('partials.chapter-select-box')
|
||||
@include('partials.chapter-paginate')
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
@endsection
|
||||
|
@ -9,9 +9,9 @@
|
||||
<h5 class="fw-bold mb-4">
|
||||
Latest Chapters
|
||||
</h5>
|
||||
|
||||
|
||||
@forelse ($manga->chapters()->latest('id')->get() as $chapter)
|
||||
<a href="{{ route('page.chapter', [$manga->slug, $chapter->id]) }}"
|
||||
<a href="{{ route('page.chapter', [$manga->slug, $chapter->chapter_no]) }}"
|
||||
class="list-group-item list-group-item-action pb-0 border-0 border-bottom
|
||||
d-inline-block d-flex align-items-center justify-content-between">
|
||||
<p> Chapter {{ $chapter->chapter_no }} - {{ $chapter->title ?? '' }} </p>
|
||||
|
@ -1,7 +1,7 @@
|
||||
@props(['manga', 'chapter'])
|
||||
|
||||
<div class="d-flex justify-content-between flex-wrap mb-2">
|
||||
<a href="{{ route('page.chapter', [$manga->slug, $chapter->id]) }}"
|
||||
<a href="{{ route('page.chapter', [$manga->slug, $chapter->chapter_no]) }}"
|
||||
class="text-decoration-none text-white small bg-secondary rounded-pill px-1">
|
||||
Chapter {{ $chapter->chapter_no }}
|
||||
</a>
|
||||
|
@ -13,6 +13,9 @@
|
||||
<div class="mb-3">
|
||||
<label for="">Manga Cover</label>
|
||||
<input type="file" name="cover" id="" class="form-control">
|
||||
@error('cover')
|
||||
<p class="text-danger small">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="">Manga Summary</label>
|
||||
|
@ -1,4 +1,15 @@
|
||||
<div>
|
||||
<a href="" class="btn btn-dark btn-small">Previous</a>
|
||||
<a href="" class="btn btn-dark btn-small">Next</a>
|
||||
<a
|
||||
href="{{ route('page.chapter', [$manga->slug, $chapter->chapter_no - 1 ]) }}"
|
||||
class="btn btn-{{$chapter->chapter_no == 1 ? 'secondary' : 'dark' }} btn-small {"
|
||||
style="pointer-events: {{ $chapter->chapter_no == 1 ? 'none' : '' }}">
|
||||
Previous
|
||||
</a>
|
||||
<a
|
||||
href="{{ route('page.chapter', [$manga->slug, $chapter->chapter_no + 1 ]) }}"
|
||||
class="btn btn-{{ $chapter->chapter_no == $manga->chapters->last()->chapter_no ? 'secondary' : 'dark' }} btn-small"
|
||||
style="pointer-events: {{ $chapter->chapter_no == $manga->chapters->last()->chapter_no ? 'none' : '' }}"
|
||||
>
|
||||
Next
|
||||
</a>
|
||||
</div>
|
||||
|
@ -28,7 +28,7 @@
|
||||
<!--profile and logout -->
|
||||
@auth
|
||||
<div class="btn btn-outline-dark dropdown ms-3">
|
||||
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button"
|
||||
<a id="navbarDropdown" class="nav-link dropdown-toggle" role="button"
|
||||
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
|
||||
<i class="bi bi-person-circle"></i> {{ Auth::user()->name }}
|
||||
</a>
|
||||
|
@ -13,7 +13,10 @@
|
||||
@endguest
|
||||
|
||||
@auth
|
||||
<a href="{{ route('home') }}" class="btn btn-sm btn-dark rounded-pill"> <i class="bi bi-speedometer"></i> Go To Dashboard</a>
|
||||
@can('admin-only')
|
||||
<a href="{{ route('home') }}" class="btn btn-sm btn-dark rounded-pill"> <i class="bi bi-speedometer"></i> Go To
|
||||
Dashboard</a>
|
||||
@endcan
|
||||
@endauth
|
||||
</div>
|
||||
</ul>
|
||||
|
@ -23,7 +23,7 @@ use Illuminate\Support\Facades\Route;
|
||||
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')->name('page.chapter');
|
||||
Route::get('/manga/{manga:slug}/chapter/{chapter:chapter_no?}', 'chapter')->name('page.chapter');
|
||||
});
|
||||
|
||||
Auth::routes();
|
||||
|
Loading…
x
Reference in New Issue
Block a user