<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
@foreach($comments as $comment)
    <div class="display-comment">
<p> หมายเลขผู้ใช้ {{$user_id}}  </p>
        <p>{{ $comment->body }}</p>


        <a href="" id="reply"></a>
        <form method="post" action="{{ route('reply.add') }}">
            @csrf
            <div class="form-group">
                <input type="text" name="comment_body" class="form-control" required/>
                <input type="hidden" name="post_id" value="{{ $post_id }}" />
                <input type="hidden" name="comment_id" value="{{ $comment->id }}" />
            </div>

            <form method="get" class="delete_form" action="{{ route('comment.destroy', $comment->id) }}">
            <div class="form-group">

                  <input type="submit" class="btn btn-primary delete_form"   value="answerer" />
                  @if($comment->user_id == $user_id)
                  <a href="{{ route('comment.destroy', $comment->id) }}" class="btn btn-primary delete_form"> <i class="fa fa-trash fa-1x"></i> Delete</a>

            </div>
              @endif
        </form>
        @include('comment/_comment_replies', ['comments' => $comment->replies])
    </div>
    <script>
    $(document).ready(function(){
        $('.delete_form').on('submit',function(){
        if(confirm("คุณต้องการลบข้อมูลหรือไม่?")){
            return ture;
        }
        else {
            return false;
        }
        });
    });



    </script>
@endforeach
