-
app/Livewire/Comments.php
Open in GitHubuse App\Models\Comment; use Livewire\Component; use Illuminate\View\View; class Comments extends Component { public int $postId; public function render() : View { return view('livewire.comments', [ 'comments' => Comment::query() ->where('post_id', $this->postId) ->whereNull('parent_id') ->paginate(30), 'commentsCount' => Comment::query() ->where('post_id', $this->postId) ->count(), ]); } }
-
resources/views/livewire/comments.blade.php
Open in GitHub<div> <h1 class="font-bold tracking-widest text-center text-black uppercase"> {{ trans_choice(':count comment|:count comments', $commentsCount) }} </h1> <div class="grid gap-8 mt-8"> @foreach ($comments as $comment) <x-comment :$comment /> @endforeach </div> </div>
-
resources/views/posts/show.blade.php
Open in GitHub// ... <x-section id="comments" class="mt-12 md:mt-16 lg:max-w-(--breakpoint-md)" > <livewire:comments :post-id="$post->id" /> </x-section> // ...