diff --git a/app/Helpers/CacheHelper.php b/app/Helpers/CacheHelper.php index 155e044..cde2cee 100644 --- a/app/Helpers/CacheHelper.php +++ b/app/Helpers/CacheHelper.php @@ -2,6 +2,7 @@ namespace App\Helpers; +use App\Models\Comment; use App\Models\Episode; use App\Models\Hentai; use App\Models\PopularMonthly; @@ -126,7 +127,7 @@ class CacheHelper public static function getLatestComments() { return Cache::remember("latest_comments", now()->addMinutes(60), function () { - return DB::table('comments')->latest()->take(10)->get(); + return Comment::latest()->take(10)->get(); }); } } diff --git a/resources/views/home/partials/comments.blade.php b/resources/views/home/partials/comments.blade.php index 9a9eb7c..01c3258 100644 --- a/resources/views/home/partials/comments.blade.php +++ b/resources/views/home/partials/comments.blade.php @@ -2,14 +2,14 @@ {{ __('home.latest-comments') }}

-
+
@foreach ($latestComments as $comment) @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
-
- {{--@include('partials.comment', ['comment' => $comment])--}} +
+ @include('partials.comment', ['comment' => $comment])
@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 @endif diff --git a/resources/views/partials/comment.blade.php b/resources/views/partials/comment.blade.php new file mode 100644 index 0000000..1e3b6bc --- /dev/null +++ b/resources/views/partials/comment.blade.php @@ -0,0 +1,26 @@ +
+
+
+ {{ $comment->user->name }} +
+
+
+

{{ $comment->user->name }}

+ @if($comment->user->is_admin) + + @endif + @if($comment->user->is_patreon) + + @endif +
+
+
{!! $comment->presenter()->markdownBody() !!}
+
+
+ + {{ $comment->presenter()->relativeCreatedAt() }} + +
+
+
+
\ No newline at end of file