laravel 停止循环中的嵌套回复表单
laravel stop nested reply form in loop
我怎样才能阻止回复表单在回复后显示和重复自己
@foreach($comments as $comment)
<div class="display-comment">
<strong>{{ $comment->user->name }}</strong>
<p>{{ $comment->comment }}</p>
<a href="" id="reply"></a>
<form method="post" action="{{ route('reply.add') }}">
@csrf
<div class="form-group">
<input type="text" name="comment" class="form-control" />
<input type="hidden" name="post_id" value="{{ $post_id }}" />
<input type="hidden" name="comment_id" value="{{ $comment->id }}" />
</div>
<div class="form-group">
<input type="submit" class="py-0 btn btn-sm btn-outline-danger" style="font-size: 0.8em;" value="Reply" />
</div>
</form>
@include('posts.comments.reply', ['comments' => $comment->replies])
</div>
@endforeach
你应该能想出来。没那么棘手
@if (!empty($comment->replies))
@include('posts.comments.reply', ['comments' => $comment->replies])
@empty
@forelse($comments as $comment)
<div class="display-comment">
<strong>{{ $comment->user->name }}</strong>
<p>{{ $comment->comment }}</p>
@include('posts.comments.reply', ['comments' => $comment->replies])
</div>
@empty
<div> No comments found</div>
@endforelse
<form method="post" action="{{ route('reply.add') }}">
@csrf
<div class="form-group">
<input type="text" name="comment" class="form-control" />
<input type="hidden" name="post_id" value="{{ $post_id }}" />
<input type="hidden" name="comment_id" value="{{ $comment->id }}" />
</div>
<div class="form-group">
<input type="submit" class="py-0 btn btn-sm btn-outline-danger" style="font-size: 0.8em;" value="Reply" />
</div>
</form>
我怎样才能阻止回复表单在回复后显示和重复自己
@foreach($comments as $comment)
<div class="display-comment">
<strong>{{ $comment->user->name }}</strong>
<p>{{ $comment->comment }}</p>
<a href="" id="reply"></a>
<form method="post" action="{{ route('reply.add') }}">
@csrf
<div class="form-group">
<input type="text" name="comment" class="form-control" />
<input type="hidden" name="post_id" value="{{ $post_id }}" />
<input type="hidden" name="comment_id" value="{{ $comment->id }}" />
</div>
<div class="form-group">
<input type="submit" class="py-0 btn btn-sm btn-outline-danger" style="font-size: 0.8em;" value="Reply" />
</div>
</form>
@include('posts.comments.reply', ['comments' => $comment->replies])
</div>
@endforeach
你应该能想出来。没那么棘手
@if (!empty($comment->replies))
@include('posts.comments.reply', ['comments' => $comment->replies])
@empty
@forelse($comments as $comment)
<div class="display-comment">
<strong>{{ $comment->user->name }}</strong>
<p>{{ $comment->comment }}</p>
@include('posts.comments.reply', ['comments' => $comment->replies])
</div>
@empty
<div> No comments found</div>
@endforelse
<form method="post" action="{{ route('reply.add') }}">
@csrf
<div class="form-group">
<input type="text" name="comment" class="form-control" />
<input type="hidden" name="post_id" value="{{ $post_id }}" />
<input type="hidden" name="comment_id" value="{{ $comment->id }}" />
</div>
<div class="form-group">
<input type="submit" class="py-0 btn btn-sm btn-outline-danger" style="font-size: 0.8em;" value="Reply" />
</div>
</form>