Support the ongoing development of Laravel.io →
Database Eloquent Blade
Last updated 2 years ago.
0

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.

Last updated 6 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.