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)
|
public function store(StoreChapterRequest $request)
|
||||||
{
|
{
|
||||||
|
// dd ($request->file('images'));
|
||||||
|
|
||||||
$formData = $request->validated();
|
$formData = $request->validated();
|
||||||
$formData['user_id'] = Auth::id();
|
$formData['user_id'] = Auth::id();
|
||||||
if($request->hasFile('images')) {
|
if($request->hasFile('images')) {
|
||||||
foreach ($request->file('images') as $image) {
|
foreach ($request->file('images') as $key => $image) {
|
||||||
$images[] = $image->store($request->manga_id.'OfChapter', 'public');
|
$images[] = $image->store($request->manga_id.'ChapterImages', 'public');
|
||||||
}
|
}
|
||||||
$formData['images'] = $images;
|
$formData['images'] = $images;
|
||||||
}
|
}
|
||||||
@ -89,3 +91,4 @@ class ChapterController extends Controller
|
|||||||
return view('chapter.manageChapter', compact('manga'));
|
return view('chapter.manageChapter', compact('manga'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,14 +2,16 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\Chapter;
|
|
||||||
use App\Models\Manga;
|
use App\Models\Manga;
|
||||||
|
use App\Models\Chapter;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class PageController extends Controller
|
class PageController extends Controller
|
||||||
{
|
{
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
// Storage::disk('local')->put('example.txt', 'Contents');
|
||||||
$mangas = Manga::latest('id')->paginate(8)->withQueryString();
|
$mangas = Manga::latest('id')->paginate(8)->withQueryString();
|
||||||
return view('index', [
|
return view('index', [
|
||||||
'mangas' => $mangas
|
'mangas' => $mangas
|
||||||
|
@ -22,8 +22,10 @@ class StoreChapterRequest extends FormRequest
|
|||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'min:3',
|
'title' => 'required|min:3',
|
||||||
'manga_id' => 'required|exists:mangas,id'
|
'manga_id' => 'required|exists:mangas,id',
|
||||||
|
'images' => 'required',
|
||||||
|
'images.*' => 'file|mimes:png,jpg'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +33,9 @@ class StoreChapterRequest extends FormRequest
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'manga_id.required' => 'Please Select the Manga',
|
'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 [
|
return [
|
||||||
'title' => 'required|min:3|max:100',
|
'title' => 'required|min:3|max:100',
|
||||||
'summary' => 'required|min:3',
|
'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 [
|
return [
|
||||||
'title' => 'required|min:3',
|
'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 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>
|
<a href="{{ route('chapter.index') }}" class="btn btn-dark"> <i class="bi bi-book"></i> Chapter List</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form method="POST" action="{{ route('chapter.store') }}" enctype="multipart/form-data">
|
<form method="POST" action="{{ route('chapter.store') }}" enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
@ -25,7 +25,7 @@
|
|||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<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">
|
<input type="text" name="title" class="form-control">
|
||||||
@error('title')
|
@error('title')
|
||||||
<p class="text-danger small">{{ $message }}</p>
|
<p class="text-danger small">{{ $message }}</p>
|
||||||
@ -35,6 +35,9 @@
|
|||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="">Chapter Images</label>
|
<label for="">Chapter Images</label>
|
||||||
<input type="file" name="images[]" id="" class="form-control" multiple>
|
<input type="file" name="images[]" id="" class="form-control" multiple>
|
||||||
|
@error('images')
|
||||||
|
<p class="text-danger small">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="submit" class="btn btn-outline-dark">Create</button>
|
<button type="submit" class="btn btn-outline-dark">Create</button>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
{{-- manga images --}}
|
{{-- manga images --}}
|
||||||
<div class="mb-4">
|
<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="">
|
<img src="{{ asset('storage/'.$image) }}" class="mx-auto w-50 my-0" alt="">
|
||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
@ -24,6 +24,6 @@
|
|||||||
@include('partials.chapter-select-box')
|
@include('partials.chapter-select-box')
|
||||||
@include('partials.chapter-paginate')
|
@include('partials.chapter-paginate')
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
<h5 class="fw-bold mb-4">
|
<h5 class="fw-bold mb-4">
|
||||||
Latest Chapters
|
Latest Chapters
|
||||||
</h5>
|
</h5>
|
||||||
|
|
||||||
@forelse ($manga->chapters()->latest('id')->get() as $chapter)
|
@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
|
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">
|
d-inline-block d-flex align-items-center justify-content-between">
|
||||||
<p> Chapter {{ $chapter->chapter_no }} - {{ $chapter->title ?? '' }} </p>
|
<p> Chapter {{ $chapter->chapter_no }} - {{ $chapter->title ?? '' }} </p>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
@props(['manga', 'chapter'])
|
@props(['manga', 'chapter'])
|
||||||
|
|
||||||
<div class="d-flex justify-content-between flex-wrap mb-2">
|
<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">
|
class="text-decoration-none text-white small bg-secondary rounded-pill px-1">
|
||||||
Chapter {{ $chapter->chapter_no }}
|
Chapter {{ $chapter->chapter_no }}
|
||||||
</a>
|
</a>
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="">Manga Cover</label>
|
<label for="">Manga Cover</label>
|
||||||
<input type="file" name="cover" id="" class="form-control">
|
<input type="file" name="cover" id="" class="form-control">
|
||||||
|
@error('cover')
|
||||||
|
<p class="text-danger small">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="">Manga Summary</label>
|
<label for="">Manga Summary</label>
|
||||||
|
@ -1,4 +1,15 @@
|
|||||||
<div>
|
<div>
|
||||||
<a href="" class="btn btn-dark btn-small">Previous</a>
|
<a
|
||||||
<a href="" class="btn btn-dark btn-small">Next</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>
|
</div>
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
<!--profile and logout -->
|
<!--profile and logout -->
|
||||||
@auth
|
@auth
|
||||||
<div class="btn btn-outline-dark dropdown ms-3">
|
<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>
|
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
|
||||||
<i class="bi bi-person-circle"></i> {{ Auth::user()->name }}
|
<i class="bi bi-person-circle"></i> {{ Auth::user()->name }}
|
||||||
</a>
|
</a>
|
||||||
|
@ -13,7 +13,10 @@
|
|||||||
@endguest
|
@endguest
|
||||||
|
|
||||||
@auth
|
@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
|
@endauth
|
||||||
</div>
|
</div>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -23,7 +23,7 @@ use Illuminate\Support\Facades\Route;
|
|||||||
Route::controller(PageController::class)->group(function () {
|
Route::controller(PageController::class)->group(function () {
|
||||||
Route::get('/', 'index')->name('page.index');
|
Route::get('/', 'index')->name('page.index');
|
||||||
Route::get('/MangaDex/manga/{slug}', 'manga')->name('page.manga');
|
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();
|
Auth::routes();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user