Hi Tova,
I would edit viewproduct.blade.php. In the for loop where you write the reviews check whether one of the review belongs to the current user. Before drawing the review just check whether that variable is true.
<h2>Reviews</h2>
<?php $reviewed = false; ?>
@foreach($reviews as $data)
@if($data->user['id'] == Auth::user()->id)
<?php $reviewed = true; ?>
@endif
...
@endforeach
@if(Auth::user() && Auth::user()->id == $show->order['user_id'])
@if($errors->any())
<div class="alert alert-warning">
<ul>
@foreach($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
if(!$reviewed)
//form for review (I cut the code)
@endif
@endif
in the future you will probably not display all reviews, but page them. In that case you should find the value of $reviewed with a query to the database. Either in the controller and pass it to the view or directly in the view.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community