私はすべての私のコメントをforeachするとき私はすべての私のコメントを得るが、私はその記事からのコメントだけを見たいと思う...私はどのように私のforeachで行うことができますか?その記事からのコメントを表示
デシベル:atricles
Schema::create('articles', function (Blueprint $table) {
$table->increments('id');
$table->integer('userID')->unsigned();
$table->string('title');
$table->string('url');
$table->string('username');
$table->integer('points');
$table->integer('amountComments');
$table->timestamps();
});
デシベル:コメントはこの記事入れ
<div class="comments">
@if ($article->amountComments > 0)
<ul>
@foreach ($comments as $comment)
<li>
<div class="comment-body">{{ $comment->comment }}</div>
<div class="comment-info">Posted by {{ $article->username }} on {{ $comment->created_at }}
@if ($comment->user_id == Auth::id())
<a class="btn btn-primary btn-xs edit-btn"
href="{{ route('edit_comment', ['comment' => $comment->id]) }}">edit</a>
<a class="btn btn-danger btn-xs edit-btn"
href="{{ route('delete_comment', ['comment' => $comment->id]) }}">
<i class="fa fa-btn fa-trash" title="delete"></i>delete
</a>
@endif
</div>
</li>
@endforeach
</ul>
@else
<div>
<p>No comments yet</p>
</div>
@endif
</div>
をあなたはコメントを得ているあなたのコントローラのコードを表示することができますか?あなたはちょうどwhere句を追加する必要があるように思えます。私たちはあなたのモデルの上にormコメントを得ることができます。あなたのコントローラをポストして編集することができます –