mirror of
https://github.com/HtetPhone/MangaDex.git
synced 2025-02-20 11:23:19 +08:00
passing firstChapter & lastChapter into PageControllerr
This commit is contained in:
parent
b601f09cb2
commit
d63979b5e3
@ -26,6 +26,7 @@ class LoginController extends Controller
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
|
||||
/**
|
||||
|
@ -49,7 +49,7 @@ class ChapterController extends Controller
|
||||
} else {
|
||||
//chapter number
|
||||
$manga = Manga::where('id', $request->manga_id)->first();
|
||||
$latestChap = $manga->chapters()->latest()->first()->chapter_no;
|
||||
$latestChap = $manga->chapters()->orderBy('chapter_no', 'desc')->first()->chapter_no;
|
||||
$formData['chapter_no'] = $latestChap + 1;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Manga;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HomeController extends Controller
|
||||
@ -23,7 +25,11 @@ class HomeController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('home');
|
||||
$authors = User::where('role', 'author')->get();
|
||||
$users = User::where('role', 'user')->get();
|
||||
$mangas = Manga::all();
|
||||
// dd($authors);
|
||||
return view('home', ['authors' => $authors, 'users'=> $users, 'mangas' => $mangas]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,11 +26,27 @@ class PageController extends Controller
|
||||
public function manga($slug)
|
||||
{
|
||||
$manga = Manga::where('slug', $slug)->first();
|
||||
return view('manga', compact('manga'));
|
||||
$chapters = $manga->chapters()->orderBy('chapter_no', 'desc')->paginate(10);
|
||||
$firstChapter = $manga->chapters()->orderBy('chapter_no', 'asc')->first();
|
||||
$lastChapter = $manga->chapters()->latest('chapter_no')->first();
|
||||
// dd($firstChapter);
|
||||
return view('manga',[
|
||||
'manga' => $manga,
|
||||
'chapters' => $chapters,
|
||||
'firstChapter' => $firstChapter,
|
||||
'lastChapter' => $lastChapter
|
||||
]);
|
||||
}
|
||||
|
||||
public function chapter(Manga $manga, Chapter $chapter)
|
||||
{
|
||||
return view('chapter_page', ['manga' => $manga, 'chapter' => $chapter]);
|
||||
$firstChapter = $manga->chapters()->orderBy('chapter_no', 'asc')->first();
|
||||
$lastChapter = $manga->chapters()->latest('chapter_no')->first();
|
||||
return view('chapter_page', [
|
||||
'manga' => $manga,
|
||||
'chapter' => $chapter,
|
||||
'firstChapter' => $firstChapter,
|
||||
'lastChapter' => $lastChapter
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,6 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Paginator::useBootstrap();
|
||||
Paginator::useBootstrapFive();
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ namespace App\Providers;
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
@ -17,7 +18,7 @@ class RouteServiceProvider extends ServiceProvider
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/';
|
||||
public const HOME = "/";
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, and other route configuration.
|
||||
|
@ -22,3 +22,11 @@
|
||||
.alert-msg {
|
||||
transform: translateX(-50%) translateY(10%);
|
||||
}
|
||||
|
||||
.cover-img {
|
||||
transition: all 1s;
|
||||
}
|
||||
.cover-img:hover {
|
||||
filter: grayscale(30%);
|
||||
transform: scale(1.2);
|
||||
}
|
||||
|
@ -1,26 +1,43 @@
|
||||
@props(['manga'])
|
||||
@props(['manga', 'chapters', 'firstChapter', 'lastChapter'])
|
||||
<div>
|
||||
<h5 class="fw-semibold my-3 text-primary"> <i class="bi bi-award-fill"></i> {{ $manga->title }}</h5>
|
||||
<div class="row my-3">
|
||||
<div class="col-12 col-md-4">
|
||||
<div class="text-center">
|
||||
<img class="w-25" src="{{ asset('storage/' . $manga->cover) }}" alt="">
|
||||
<img class="image-fluid" src="{{ asset('storage/' . $manga->cover) }}" alt="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-7">
|
||||
<p> <span class="fw-semibold">Author</span> - {{ $manga->user->name }} </p>
|
||||
<p> <span class="fw-semibold">Genre</span> - </p>
|
||||
<p class="d-flex">
|
||||
<a href="{{ route('page.chapter', [$manga->slug, $firstChapter->chapter_no]) }}" class="btn btn-primary me-1">Read First</a>
|
||||
<a href="{{ route('page.chapter', [$manga->slug, $lastChapter->chapter_no]) }}" class="btn btn-primary">Read Last</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="my-5">
|
||||
<h5 class="fw-semibold text-primary"> <i class="bi bi-award-fill"></i> Summary </h5>
|
||||
<hr>
|
||||
<p class="text-black-50"> {{ $manga->summary }} </p>
|
||||
</div>
|
||||
<h3 class="text-center my-3">{{ $manga->title }}</h3>
|
||||
<p> {{ $manga->summary }} </p>
|
||||
<ul class="list-group my-3 mt-5 mx-auto">
|
||||
<h5 class="fw-bold mb-4">
|
||||
Latest Chapters
|
||||
<h5 class="w-semibold text-primary">
|
||||
<i class="bi bi-award-fill"></i> Latest Chapter Release
|
||||
</h5>
|
||||
|
||||
@forelse ($manga->chapters()->orderBy('chapter_no', 'desc')->get() as $chapter)
|
||||
@forelse ($chapters as $chapter)
|
||||
<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>
|
||||
<p class="text-black-50 small">
|
||||
{{$chapter->updated_at->diffForHumans()}}
|
||||
{{ $chapter->updated_at->diffForHumans() }}
|
||||
</p>
|
||||
</a>
|
||||
@empty
|
||||
<p class="text-danger">No Chapter Yet!</p>
|
||||
@endforelse
|
||||
</ul>
|
||||
{{ $chapters->links() }}
|
||||
</div>
|
||||
|
@ -2,14 +2,16 @@
|
||||
|
||||
<div class="col-6 col-md-3">
|
||||
<div class="card border-0">
|
||||
<div class="text-center">
|
||||
<div class="text-center overflow-hidden">
|
||||
<a href="{{ route('page.manga', $manga->slug) }}">
|
||||
<img src="{{ asset( 'storage/'.$manga->cover ) }}" alt="img"
|
||||
class="w-100">
|
||||
class="w-100 cover-img">
|
||||
</a>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<a href="{{ route('page.manga', $manga->slug) }}" class="text-decoration-none">
|
||||
<h5 class="fw-semibold "> {{ $manga->title }} </h5>
|
||||
</a>
|
||||
@forelse ($manga->chapters()->latest('id')->limit(2)->get() as $chapter)
|
||||
<x-latest-chapter :manga="$manga" :chapter="$chapter" />
|
||||
@empty
|
||||
|
@ -12,6 +12,11 @@
|
||||
@endif
|
||||
|
||||
{{ __('You are logged in!') }}
|
||||
|
||||
<h5 class="text-primary fw-semibold mt-3"> <i class="bi bi-arrow-through-heart-fill"></i> Statistics</h5>
|
||||
<p>Authors : <span class="text-success">{{ $authors->count() }} {{ Str::plural('author', $authors->count())}} </span></p>
|
||||
<p>Users : <span class="text-success">{{ $users->count() }} {{ Str::plural('user', $authors->count()) }}</span> </p>
|
||||
<p>Comics : <span class="text-success">{{ $mangas->count() }} {{ Str::plural('comic', $mangas->count()) }}</span> </p>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
@ -9,7 +9,7 @@
|
||||
<a title="clear search" href="{{ route('page.index') }}" class="btn btn-danger ms-4 p-0 px-1 border-1 border-dark"> <i class="bi bi-x-lg"></i> </a>
|
||||
</div>
|
||||
@endif
|
||||
<div class="col-12 col-md-9">
|
||||
<div class="col-12 col-md-9 mb-4">
|
||||
<div class="row flex-wrap">
|
||||
@forelse ($mangas as $manga)
|
||||
<x-outter-manga-frame :manga="$manga" />
|
||||
@ -23,8 +23,8 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-md-3">
|
||||
<hr class="d-block d-md-none w-75 mx-auto text-primary">
|
||||
<div class="col-12 col-md-3 mb-4">
|
||||
@include('partials.hot-manga')
|
||||
</div>
|
||||
<div class="col-12 mt-5">
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
<div class="row mt-5">
|
||||
<div class="col-12 col-md-9">
|
||||
<x-inner-manga :manga="$manga" />
|
||||
<x-inner-manga :manga="$manga" :chapters="$chapters" :firstChapter="$firstChapter" :lastChapter="$lastChapter" />
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-md-3">
|
||||
|
@ -1,15 +1,15 @@
|
||||
<div>
|
||||
<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' : '' }}">
|
||||
class="btn btn-{{$chapter->chapter_no == $firstChapter->chapter_no ? 'secondary' : 'dark' }} btn-small {"
|
||||
style="pointer-events: {{ $chapter->chapter_no == $firstChapter->chapter_no ? 'none' : '' }}">
|
||||
Previous
|
||||
</a>
|
||||
{{-- <p> {{ }} </p> --}}
|
||||
<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' : '' }}"
|
||||
>
|
||||
class="btn btn-{{ $chapter->chapter_no == $lastChapter->chapter_no ? 'secondary' : 'dark' }} btn-small"
|
||||
style="pointer-events: {{ $chapter->chapter_no == $lastChapter->chapter_no ? 'none' : '' }}">
|
||||
Next
|
||||
</a>
|
||||
</div>
|
||||
|
@ -1,16 +1,18 @@
|
||||
<h4 class="fw-semibold">Manga Hot</h4>
|
||||
<h5 class="fw-semibold text-primary"> <i class="bi bi-award-fill"></i> Manga Hot</h5>
|
||||
<div class="row">
|
||||
@forelse (App\Models\Manga::latest('id')->limit(3)->get() as $hotManga)
|
||||
<div class="col-12 mt-3">
|
||||
<div class="d-flex border-0">
|
||||
<div>
|
||||
<div class="row border-0 flex-wrap">
|
||||
<div class="overflow-hidden col-4">
|
||||
<a href="{{ route('page.manga', $hotManga->slug) }}">
|
||||
<img src="{{ asset( 'storage/'.$hotManga->cover) }}"
|
||||
alt="img" style="max-width: 80px">
|
||||
alt="img" class="cover-img img-fluid">
|
||||
</a>
|
||||
</div>
|
||||
<div class="ms-2">
|
||||
<div class="col-8">
|
||||
<a href="{{ route('page.manga', $hotManga->slug) }}" class="text-decoration-none">
|
||||
<p class="fw-semibold mb-1"> {{ $hotManga->title }} </p>
|
||||
</a>
|
||||
|
||||
@foreach ($hotManga->chapters()->latest('id')->limit(2)->get() as $hotChap)
|
||||
<x-latest-chapter :manga="$hotManga" :chapter="$hotChap" />
|
||||
|
@ -1,4 +1,7 @@
|
||||
<ul class="list-group">
|
||||
<h5>
|
||||
<a href="{{ route('home') }}" class="list-group-item list-group-item-action text-primary"><i class="bi bi-speedometer2"></i> Dashboard </a>
|
||||
</h5>
|
||||
<h5>Manga</h5>
|
||||
<a href="{{ route('manga.index') }}" class="list-group-item list-group-item-action"><i class="bi bi-book"></i> Manga
|
||||
List </a>
|
||||
|
Loading…
x
Reference in New Issue
Block a user