の下にコメントを表示私はこのLaravel 5.4回答と私は、コメントを追加しようとする親コメント
mysql> select * from review;
+----+----------+--------+------------+---------------------+---------------------+----------+------+---------+-----------+
| id | review | rating | product_id | created_at | updated_at | approved | spam | user_id | parent_id |
+----+----------+--------+------------+---------------------+---------------------+----------+------+---------+-----------+
| 1 | how much | 2 | 25 | 2017-05-05 12:02:02 | 2017-05-05 12:02:02 | 1 | 0 | 10 | NULL |
| 2 | 20 | NULL | 25 | 2017-05-05 12:02:35 | 2017-05-05 12:02:35 | 1 | 0 | 10 | 1 |
| 3 | ok | NULL | 31 | 2017-05-08 05:09:01 | 2017-05-08 05:09:01 | 1 | 0 | 9 | 2 |
| 4 | 30 | NULL | 31 | 2017-05-08 05:25:47 | 2017-05-08 05:25:47 | 1 | 0 | 9 | 3 |
| 5 | 40 | NULL | 31 | 2017-05-08 05:26:21 | 2017-05-08 05:26:21 | 1 | 0 | 9 | 4 |
| 6 | not fair | NULL | 31 | 2017-05-08 05:27:16 | 2017-05-08 05:27:16 | 1 | 0 | 9 | 5 |
| 7 | 80 | NULL | 31 | 2017-05-08 05:29:26 | 2017-05-08 05:29:26 | 1 | 0 | 9 | 1 |
| 8 | hi | NULL | 29 | 2017-05-08 05:37:25 | 2017-05-08 05:37:25 | 1 | 0 | 9 | NULL |
+----+----------+--------+------------+---------------------+---------------------+----------+------+---------+-----------+
などの見直しテーブルを持っている私が欲しいものを正確に彼らの親IDを格納.ITになりましたどのように私はこれを達成することができます...親コメントの下
コメントを表示します?
機能ストアのレビューに:
私のコントローラで私は、コメントを表示するために
機能2機能を使用しています
public function review($id,Request $request){
$userid = Auth::user()->id;
$product = Product::find($id);
$product = Product::find($id);
$input = array(
'review' => Input::get('review'),
'rating' => Input::get('rating'),
'parent_id' => Input::get('parent_id')
);
$review = new Review;
$validator = Validator::make($input, $review->getCreateRules());
if ($validator->passes()) {
$review->storeReviewForProduct($id, $input['review'], $input['rating'],$input['parent_id']);
return redirect('product-detail/'.$id.'#reviews-anchor')->with('review_posted',true);
}
return Redirect::to('product-detail/'.$id.'#reviews-anchor')->withErrors($validator)->withInput();
}
これが私の見解である:
@foreach($reviews as $val)
<div class="row">
<div class="col-md-12">
<p>{{$val['review']}} <span class="reply-comment">Reply</span></p>
{{-- Start Comment --}}
<div class="comment-box" style="display:none;">
<form action="{{ route('product.review',['id'=>$getProduct->id]) }}" method="post" id="comment">
{{csrf_field()}}
<input type="hidden" value="{{$val['id']}}" name="parent_id" id="parent_id">
<textarea class="form-control animated" cols="50" id="new-comment" name="review" placeholder="Leave your comment here" rows="5"></textarea>
<div class="text-right">
<button class="bc-btn-cancel-review" href="#" id="close-comment">Close</button>
<button class="bc-btn-save-review" type="submit" id="review">Comment</button>
</div>
</form>
</div>
{{-- End Comment --}}
</div>
</div>
@endforeach
私は画像
あなたのモデルは、あなたがどんな関係を定義なかった私たちに示して?あなたは何をあなたの意見に伝えますか? –
は、あなたがこれまで働いてきたコードを表示することができますか..?私のコードを編集 –
...あなたはそれを – Karthiga