@if(count($comments) > 0)
Most recent
@endif @forelse($comments as $comment)
@php $user = App\Models\User::where('id', $comment->user_id)->first(); @endphp
{{$user->first_name}} {{$user->last_name}}
{{$comment->created_at->diffForHumans()}}

{{$comment->comment_body}}

@php $comment_like_count = App\Models\CommentLike::where('comment_id', $comment->id)->where('feed_id', $feed->id)->where('like', 1)->count(); @endphp @if($comment_like_count > 0 && $comment_like_count < 2) {{$comment_like_count}} like @elseif($comment_like_count > 1) {{$comment_like_count}} likes @else {{$comment_like_count}} like @endif . @php $comment_reply_count = App\Models\CommentReply::where('comment_id', $comment->id)->where('feed_id', $feed->id)->count(); @endphp {{$comment_reply_count}} @if($comment_reply_count <= 1) reply @elseif($comment_reply_count > 1) replies @endif
@php $comment_likes = App\Models\CommentLike::where('comment_id', $comment->id)->where('feed_id', $feed->id)->get(); $user_has_liked_comment = App\Models\CommentLike::where('comment_id', $comment->id)->where('feed_id', $feed->id)->where('user_id', Auth::user()->id)->where('like', 1)->first(); $user_has_unliked_comment = App\Models\CommentLike::where('comment_id', $comment->id)->where('feed_id', $feed->id)->where('user_id', Auth::user()->id)->where('like', 0)->first(); $user_has_not_liked_comment = App\Models\CommentLike::where('comment_id', $comment->id)->where('feed_id', $feed->id)->where('user_id', '<>', Auth::user()->id)->count(); @endphp @if(count($comment_likes) > 0) @if($user_has_liked_comment) @elseif($user_has_unliked_comment) @elseif($user_has_not_liked_comment < 1) @endif @else @endif Reply
@csrf
@php $comment_replies = App\Models\CommentReply::where('comment_id', $comment->id)->orderBy('created_at', 'ASC')->get(); $all_replies = App\Models\CommentReply::where('comment_id', $comment->id)->count(); @endphp
@forelse($comment_replies as $comment_reply)
@php $user = App\Models\User::where('id', $comment_reply->user_id)->first(); @endphp
{{$user->first_name}} {{$user->last_name}}
{{$comment_reply->created_at->diffForHumans()}}

{{$comment_reply->comment_reply_body}}

@php $comment_reply_like_count = App\Models\CommentReplyLike::where('comment_reply_id', $comment_reply->id)->where('comment_id', $comment->id)->where('like', 1)->count(); @endphp @if($comment_reply_like_count > 0 && $comment_reply_like_count < 2) {{$comment_reply_like_count}} like @elseif($comment_reply_like_count > 1) {{$comment_reply_like_count}} likes @else {{$comment_reply_like_count}} like @endif
@php $comment_reply_likes = App\Models\CommentReplyLike::where('comment_reply_id', $comment_reply->id)->where('comment_id', $comment->id)->get(); $user_has_liked_comment_reply = App\Models\CommentReplyLike::where('comment_reply_id', $comment_reply->id)->where('comment_id', $comment->id)->where('user_id', Auth::user()->id)->where('like', 1)->first(); $user_has_unliked_comment_reply = App\Models\CommentReplyLike::where('comment_reply_id', $comment_reply->id)->where('comment_id', $comment->id)->where('user_id', Auth::user()->id)->where('like', 0)->first(); $user_has_not_liked_comment_reply = App\Models\CommentReplyLike::where('comment_reply_id', $comment_reply->id)->where('comment_id', $comment->id)->where('user_id', '<>', Auth::user()->id)->count(); @endphp @if(count($comment_reply_likes) > 0) @if($user_has_liked_comment_reply) @elseif($user_has_unliked_comment_reply) @elseif($user_has_not_liked_comment_reply < 1) @endif @else @endif
@empty @endforelse
{{-- @if($all_replies > 2)
Load more replies..
@endif --}}
@empty @endforelse