title: Laravel - how to make a review by buyer for the product?
body: <p>I want to ask Bro, how to make a product review by the user who has bought the goods, I've tried to make, but not successful, the result is like this:</p>
  
  <p>first, if the user (buyer) buy the goods and do the review is successful, but the form for the review is still there ... how do I remove the form for the user (buyer) who has done a review for the goods?</p>
  
  <p><a href="https://i.stack.imgur.com/z8t5B.png" rel="nofollow noreferrer">can do a review, when the product has not been reviewed #View Image</a></p>
  
  <p><a href="https://i.stack.imgur.com/tlmfA.png" rel="nofollow noreferrer">the form still exists despite having reviewed the goods #View Image</a></p>
  
  <p>secondly, it is already purchased and reviewed by other users, the user (buyer with different account) make a purchase and succeed, but if make a review of the same item, can not the form does not appear, but already made a purchase ..</p>
  
  <p><a href="https://i.stack.imgur.com/imkGC.png" rel="nofollow noreferrer">there is no form for the user, even after making a purchase #View Image</a></p>
  
  <p><strong>essentially like this</strong>
  if the goods have not been reviewed, can do the review and the form is still there even though it has done a review.
  but if you already have a review, other users (buyers) can not review the item (the form does not appear).
  well that's the problem where is Bro ?, in conditioning _ (if) _? or anything else?</p>
  
  <p><strong>viewproduct.blade.php</strong></p>
  
  <pre><code>&lt;div role="tabpanel" class="tab-pane fade" id="profile"&gt;
  &lt;h2&gt;Reviews&lt;/h2&gt;
  @foreach($reviews as $data)
  &lt;div class="panel panel-default"&gt;
      &lt;div class="panel-body"&gt;
          &lt;h4&gt;{{ $data-&gt;user['name'] }}&lt;/h4&gt;
          &lt;p&gt;{{ $data-&gt;ulasan }}&lt;/p&gt;
          &lt;h3&gt;{{ $data-&gt;rating }}&lt;/h3&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  @endforeach
  @if(Auth::user() &amp;&amp; Auth::user()-&gt;id == $show-&gt;order['user_id'])
  @if($errors-&gt;any())
  &lt;div class="alert alert-warning"&gt;
  &lt;ul&gt;
  @foreach($errors-&gt;all() as $error)
  &lt;li&gt;{{ $error }}&lt;/li&gt;
  @endforeach
  &lt;/ul&gt;
  &lt;/div&gt;
  @endif
  //form for review (I cut the code)
  @endif
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>StoreController.php</strong></p>
  
  <pre><code>public function ViewProduct($id)
  {
      $show = Products::findOrFail($id);
      $related = Products::where('kategori_id', $show-&gt;kategori_id)
      -&gt;orderByRaw('RAND()')
      -&gt;take(10)
      -&gt;get();
      $reviews = Reviews::where('product_id', $show-&gt;id)-&gt;get();
      return view('shop.viewproduct', compact('show','related','order','reviews'));
  }
  
  public function StoreReviewProduct(Request $request)
  {
      $this-&gt;validate($request, [
          'rating' =&gt; 'required',
          'description' =&gt; 'required|min:10',
      ]);
      $addreview = new Reviews([
          'product_id' =&gt; $request['product_id'],
          'user_id' =&gt; Auth::user()-&gt;id,
          'rating' =&gt; $request['rating'],
          'description' =&gt; $request['description']
      ]);
      $addreview-&gt;save();
      Session::flash('success','thanks for adding review!');
      return redirect()-&gt;back();
  }
  </code></pre>
  
  <p><strong>Products(Model).php</strong></p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class Products extends Model
  {
      protected $fillable = ['kategori_id','nama_product','deskripsi','harga','pict','stok','review','id_kios'];
  
      public function kios()
      {
          return $this-&gt;belongsTo(Kios::class,'id_kios');
      }
  
      public function order()
      {
          return $this-&gt;belongsTo(Orders::class,'id','product_id');
      }
  }
  </code></pre>
  
  <p>thanks a lot for the answer :)</p>