Add comments to home page
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Helpers;
|
namespace App\Helpers;
|
||||||
|
|
||||||
|
use App\Models\Comment;
|
||||||
use App\Models\Episode;
|
use App\Models\Episode;
|
||||||
use App\Models\Hentai;
|
use App\Models\Hentai;
|
||||||
use App\Models\PopularMonthly;
|
use App\Models\PopularMonthly;
|
||||||
@@ -126,7 +127,7 @@ class CacheHelper
|
|||||||
public static function getLatestComments()
|
public static function getLatestComments()
|
||||||
{
|
{
|
||||||
return Cache::remember("latest_comments", now()->addMinutes(60), function () {
|
return Cache::remember("latest_comments", now()->addMinutes(60), function () {
|
||||||
return DB::table('comments')->latest()->take(10)->get();
|
return Comment::latest()->take(10)->get();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
{{ __('home.latest-comments') }}
|
{{ __('home.latest-comments') }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="grid grid-cols-1 gap-2 md:grid-cols-2">
|
<div class="grid gap-2 grid-cols-1 xl:grid-cols-2">
|
||||||
@foreach ($latestComments as $comment)
|
@foreach ($latestComments as $comment)
|
||||||
@if ($comment->commentable_type == \App\Models\Episode::class)
|
@if ($comment->commentable_type == \App\Models\Episode::class)
|
||||||
@php $episode = cache()->rememberForever('commentEpisode'.$comment->commentable_id, fn () => App\Models\Episode::with('gallery')->where('id', $comment->commentable_id)->first()); @endphp
|
@php $episode = cache()->rememberForever('commentEpisode'.$comment->commentable_id, fn () => App\Models\Episode::with('gallery')->where('id', $comment->commentable_id)->first()); @endphp
|
||||||
<div id="comments" class="flex p-4 bg-white rounded-lg dark:bg-neutral-950">
|
<div id="comments" class="flex p-4 bg-white rounded-lg dark:bg-neutral-950">
|
||||||
<div
|
<div
|
||||||
class="w-[20vw] mr-5 p-1 md:p-2 mb-8 relative transition ease-in-out hover:-translate-y-1 hover:scale-110 duration-300">
|
class="w-[15vw] mr-5 p-1 md:p-2 mb-4 relative transition ease-in-out hover:-translate-y-1 hover:scale-110 duration-300">
|
||||||
<a class="hidden hover:text-blue-600 xl:block"
|
<a class="hidden 2xl:block"
|
||||||
href="{{ route('hentai.index', ['title' => $episode->slug]) }}">
|
href="{{ route('hentai.index', ['title' => $episode->slug]) }}">
|
||||||
<img alt="{{ $episode->title }} - {{ $episode->episode }}" loading="lazy" width="1000"
|
<img alt="{{ $episode->title }} - {{ $episode->episode }}" loading="lazy" width="1000"
|
||||||
class="block object-cover object-center relative z-20 rounded-lg aspect-video"
|
class="block object-cover object-center relative z-20 rounded-lg aspect-video"
|
||||||
@@ -18,28 +18,28 @@
|
|||||||
class="absolute right-2 top-2 bg-rose-700/70 !text-white rounded-bl-lg rounded-tr-lg p-1 pr-2 pl-2 font-semibold text-sm z-30">
|
class="absolute right-2 top-2 bg-rose-700/70 !text-white rounded-bl-lg rounded-tr-lg p-1 pr-2 pl-2 font-semibold text-sm z-30">
|
||||||
{{ $episode->getResolution() }}</p>
|
{{ $episode->getResolution() }}</p>
|
||||||
<div class="absolute w-[95%] grid grid-cols-1 text-center">
|
<div class="absolute w-[95%] grid grid-cols-1 text-center">
|
||||||
<p class="text-sm text-center text-black dark:text-white">{{ $episode->title }} -
|
<p class="text-sm text-center text-black dark:text-white truncate">{{ $episode->title }} -
|
||||||
{{ $episode->episode }}</p>
|
{{ $episode->episode }}</p>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="block hover:text-blue-600 xl:hidden"
|
<a class="block 2xl:hidden"
|
||||||
href="{{ route('hentai.index', ['title' => $episode->slug]) }}">
|
href="{{ route('hentai.index', ['title' => $episode->slug]) }}">
|
||||||
<img alt="{{ $episode->title }} - {{ $episode->episode }}" loading="lazy" width="1000"
|
<img alt="{{ $episode->title }} - {{ $episode->episode }}" loading="lazy" width="1000"
|
||||||
class="block object-cover object-center relative z-20 rounded-lg"
|
class="block object-cover object-center relative z-20 rounded-lg"
|
||||||
src="{{ $episode->cover_url }}"></img>
|
src="{{ $episode->cover_url }}"></img>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="w-[60vw]">
|
<div class="w-[60vw] pt-4">
|
||||||
{{--@include('partials.comment', ['comment' => $comment])--}}
|
@include('partials.comment', ['comment' => $comment])
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@elseif($comment->commentable_type == \App\Models\Hentai::class)
|
@elseif($comment->commentable_type == \App\Models\Hentai::class)
|
||||||
@php $hentai = cache()->rememberForever('commentHentai'.$comment->commentable_id, fn () => App\Models\Hentai::with('gallery', 'episodes')->where('id', $comment->commentable_id)->first()); @endphp
|
@php $hentai = cache()->rememberForever('commentHentai'.$comment->commentable_id, fn () => App\Models\Hentai::with('gallery', 'episodes')->where('id', $comment->commentable_id)->first()); @endphp
|
||||||
<div id="comments" class="flex p-4 bg-white rounded-lg dark:bg-neutral-950">
|
<div id="comments" class="flex p-4 bg-white rounded-lg dark:bg-neutral-950">
|
||||||
<div
|
<div
|
||||||
class="w-[20vw] mr-5 p-1 md:p-2 mb-8 relative transition ease-in-out hover:-translate-y-1 hover:scale-110 duration-300">
|
class="w-[15vw] mr-5 p-1 md:p-2 mb-8 relative transition ease-in-out hover:-translate-y-1 hover:scale-110 duration-300">
|
||||||
<a class="hover:text-blue-600" href="{{ route('hentai.index', ['title' => $hentai->slug]) }}">
|
<a class="hidden 2xl:block" href="{{ route('hentai.index', ['title' => $hentai->slug]) }}">
|
||||||
<img alt="{{ $hentai->episodes->first()->title }}" loading="lazy" width="1000"
|
<img alt="{{ $hentai->episodes->first()->title }}" loading="lazy" width="1000"
|
||||||
class="block object-cover object-center relative z-20 rounded-lg aspect-video"
|
class="block object-cover object-center relative z-20 rounded-lg aspect-video"
|
||||||
src="{{ $hentai->gallery->first()->thumbnail_url }}"></img>
|
src="{{ $hentai->gallery->first()->thumbnail_url }}"></img>
|
||||||
@@ -47,13 +47,20 @@
|
|||||||
class="absolute right-2 top-2 bg-rose-700/70 !text-white rounded-bl-lg rounded-tr-lg p-1 pr-2 pl-2 font-semibold text-sm z-30">
|
class="absolute right-2 top-2 bg-rose-700/70 !text-white rounded-bl-lg rounded-tr-lg p-1 pr-2 pl-2 font-semibold text-sm z-30">
|
||||||
{{ $hentai->episodes->first()->getResolution() }}</p>
|
{{ $hentai->episodes->first()->getResolution() }}</p>
|
||||||
<div class="absolute w-[95%] grid grid-cols-1 text-center">
|
<div class="absolute w-[95%] grid grid-cols-1 text-center">
|
||||||
<p class="text-sm text-center text-black dark:text-white">
|
<p class="text-sm text-center text-black dark:text-white truncate">
|
||||||
{{ $hentai->episodes->first()->title }}</p>
|
{{ $hentai->episodes->first()->title }}</p>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
<a class="block 2xl:hidden"
|
||||||
|
href="{{ route('hentai.index', ['title' => $hentai->slug]) }}">
|
||||||
|
<img alt="{{ $hentai->episodes->first()->title }}" loading="lazy" width="1000"
|
||||||
|
class="block object-cover object-center relative z-20 rounded-lg"
|
||||||
|
src="{{ $hentai->episodes->first()->cover_url }}"></img>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="w-[60vw]">
|
<div class="w-[60vw]">
|
||||||
{{--@include('partials.comment', ['comment' => $comment])--}}
|
@include('partials.comment', ['comment' => $comment])
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
26
resources/views/partials/comment.blade.php
Normal file
26
resources/views/partials/comment.blade.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<div>
|
||||||
|
<div class="flex">
|
||||||
|
<div class="flex-shrink-0 mr-4">
|
||||||
|
<img class="h-10 w-10 rounded-full" src="{{ $comment->user->getAvatar() }}" alt="{{ $comment->user->name }}">
|
||||||
|
</div>
|
||||||
|
<div class="flex-grow">
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<p class="font-medium text-gray-900 dark:text-gray-100">{{ $comment->user->name }}</p>
|
||||||
|
@if($comment->user->is_admin)
|
||||||
|
<a data-te-toggle="tooltip" title="Admin"><i class="fa-solid fa-crown text-yellow-600"></i></a>
|
||||||
|
@endif
|
||||||
|
@if($comment->user->is_patreon)
|
||||||
|
<a data-te-toggle="tooltip" title="Badge of appreciation for the horny people supporting us! :3"><i class="fa-solid fa-hand-holding-heart text-rose-600"></i></a>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
<div class="mt-1 flex-grow w-full">
|
||||||
|
<div class="text-gray-700 dark:text-gray-200">{!! $comment->presenter()->markdownBody() !!}</div>
|
||||||
|
</div>
|
||||||
|
<div class="mt-2 space-x-2">
|
||||||
|
<span class="text-gray-500 dark:text-gray-300 font-medium">
|
||||||
|
{{ $comment->presenter()->relativeCreatedAt() }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user