@php $status = $comment->status ?? 'active'; $badgeClass = $status === 'active' ? 'bg-success' : ($status === 'pending' ? 'bg-warning text-dark' : 'bg-secondary'); $canEdit = auth()->check() && (auth()->id() === $comment->user_id || Gate::allows('delete-comment', [$comment, $comment->commentable])); $canDelete = auth()->check() && (auth()->id() === $comment->user_id || Gate::allows('delete-comment', [$comment, $comment->commentable])); $canVote = auth()->check() && auth()->id() !== $comment->user_id; $userVote = auth()->check() ? $comment ->votes() ->where('user_id', auth()->id()) ->first() : null; $canReply = Gate::allows('reply-comment', [$comment, $comment->commentable]); // Background color for unapproved comments $bgClass = $comment->is_approved ? '' : 'bg-light-subtle'; $isAnswer = $comment->is_answer ?? false; $totalScore = ($comment->upvote_count ?? 0) - ($comment->downvote_count ?? 0); // Determine score badge color $scoreBadgeClass = 'bg-secondary'; if ($totalScore > 0) { $scoreBadgeClass = 'bg-success'; } elseif ($totalScore < 0) { $scoreBadgeClass = 'bg-danger'; } // Check if user can perform admin actions $isAdminOrModerator = Gate::allows('admin-action', $comment); $isThreadOwner = auth()->check() && auth() ->user() ->can('markAnswer', [$comment->commentable, $comment]); // Comment border based on status @endphp @push('css') @endpush
(isset($isDisabled) && $isDisabled) || (!(isset($isChangeStatusDisabled) && $isChangeStatusDisabled) && !$comment->is_approved), 'border-best-answer' => (!(isset($isMarkAsAnswerDisabled) && $isMarkAsAnswerDisabled) && $comment->is_answer), ])> {{-- Status Badges in Top Right --}}
@if (!(isset($isMarkAsAnswerDisabled) && $isMarkAsAnswerDisabled) && $isAnswer) {{ __('labels.best_answer') }} @endif @if (!(isset($isChangeStatusDisabled) && $isChangeStatusDisabled) && $comment->is_approved && !$isAnswer) {{ __('labels.approved') }} @endif
{{-- Pending Approval Badge in Top Left --}} @if (!(isset($isChangeStatusDisabled) && $isChangeStatusDisabled) && !$comment->is_approved)
{{-- --}} {{ __('labels.pending') }}
@endif {{-- Comment Header --}}
@php $commentUser = $comment?->user; @endphp {{--
--}}
{{-- {{ $comment?->user?->name }} --}} @if(!empty($commentUser?->profile_image)) {{ $commentUser->name }} @else {{ $commentUser?->name }} @endif @if (!(isset($isMarkAsAnswerDisabled) && $isMarkAsAnswerDisabled) && $isAnswer) @endif
{{--
{{ $commentUser?->name }}
{{ $comment->created_at->diffForHumans() }} @if ($comment->updated_at != $comment->created_at) {{ __('labels.edited') }} @endif
--}}
{{ $commentUser?->name }}
{{ $comment->created_at->diffForHumans() }} @if ($comment->updated_at != $comment->created_at) {{ __('labels.edited') }} @endif
@if($commentUser->id != auth()->id())
{{-- View profile --}} @can('view', $commentUser) @endcan {{-- Direct chat: go to chats index and let frontend open/create chat --}}
@endif
{{-- Quick Actions for Admin/Thread Owner --}}
@if ($isAdminOrModerator) {{-- Mark as Answer (Thread Owner) --}} @if (!(isset($isMarkAsAnswerDisabled) && $isMarkAsAnswerDisabled)) @if ( $comment->is_approved && !$isAnswer ) @elseif( $comment->is_approved && $isAnswer ) @endif @endif {{-- Approval Controls (Admin) --}} @if (!(isset($isChangeStatusDisabled) && $isChangeStatusDisabled)) @if (!$comment->is_approved) @else @endif @endif @endif
{{-- Comment Body --}}
{{-- Voting Section (Left Side) --}}
@if (isset($isDisabled) && $isDisabled)
{{ $disabledMessage ?? 'Locked' }}
@elseif(!(isset($isVotingDisabled) && $isVotingDisabled) && $canVote && $comment->is_approved) {{ $totalScore }} @elseif(!(isset($isChangeStatusDisabled) && $isChangeStatusDisabled) && !$comment->is_approved)
{{ __('labels.awaiting_approval') }}
@elseif(!(isset($isVotingDisabled) && $isVotingDisabled))
{{ $totalScore }}
{{ __('labels.votes') }}
@endif
{{-- Comment Content --}}
{!! nl2br(e($comment->content)) !!}
{{-- Stats Bar --}} @if (!(isset($isVotingDisabled) && $isVotingDisabled))
{{ $comment->upvote_count ?? 0 }} {{ $comment->downvote_count ?? 0 }} {{-- {{ $comment->views_count ?? 0 }} --}}
@endif
{{-- Action Bar --}}
{{-- Left: User Actions --}}
{{-- Reply Button --}} @auth @if ($depth < 1 && $comment->is_approved) @if (isset($isDisabled) && $isDisabled) @elseif($canReply) @endif @endif @endauth {{-- Edit Button --}} @if (Gate::allows('edit-comment', $comment)) @endif
{{-- Right: Admin/Menu Actions --}}
{{-- Score Display --}} @if (!(isset($isVotingDisabled) && $isVotingDisabled) && $comment->is_approved)
{{ $totalScore }} {{ __('labels.points') }}
@endif {{-- More Actions Dropdown --}}
{{-- {{ __('labels.edit_comment') }} Form --}}
{{ __('labels.edit_comment') }}
@csrf @method('PUT')
{{ strlen($comment->content) }}/2000 {{ __('labels.characters') }}
{{-- Reply Form --}}
{{ __('labels.reply_to_comment') }}
@csrf
0/2000 {{ __('labels.characters') }}
{{-- Child Comments --}} @if ($comment->childrenRecursiveVisible && $comment->childrenRecursiveVisible->count() > 0)
@foreach ($comment->childrenRecursiveVisible->sortBy('created_at') as $childComment) @include('components.comments.comment', [ 'comment' => $childComment, 'depth' => $depth + 1, 'marginLeft' => 0, 'commentableId' => $commentableId, 'commentableType' => $commentableType, ]) @endforeach
@endif