title: how to prevent data re entering on database on page refresh on laravel
body: <p>I have a POS under development and I noticed that when I reload the page, it re-enters the data. How do you prevent the data from re entering on page reload?</p>
  
  <p>My Controller has this code:</p>
  
  <pre><code>public function DoAddSales(Request $request) 
  {      
      $rules = [
          'customer_name'=&gt;'required|alpha',
          'or_number'=&gt;'required',
          'payment'=&gt;'required',
      ];  
  
      $validator = Validator::make($request-&gt;all(),$rules);
  
      if ($validator-&gt;fails()) {
          return back()-&gt;withErrors($validator); 
      } else {
          foreach ($request-&gt;input('id_item') as $id) {
              $item_id[] = $id; 
          }
  
          foreach ($request-&gt;input('i_name') as $name) {
              $i_name[] = $name; 
          }
  
          foreach ($request-&gt;input('id_categ') as $categ) {
              $categ_id[] = $categ; 
          }
  
          foreach ($request-&gt;input('quan') as $quan) {
              $quantity[] = $quan; 
          }
  
          foreach ($request-&gt;input('tot') as $total) {
              $each_total[] = $total; 
          }
  
          $last = sizeof($request-&gt;input('id_item'));       
          $i = 0;
  
          while ($i &lt; $last) { 
              $items = Item::find($item_id[$i]);       
              $sales = new sales;    
              $sales-&gt;or = $request-&gt;input('or_number');
              $sales-&gt;customer_name = $request-&gt;input('customer_name');
              $sales-&gt;item_id = $item_id[$i];
              $sales-&gt;item_name = $i_name[$i];
              $sales-&gt;category_id = $categ_id[$i];
              $sales-&gt;user_id = Auth::user()-&gt;id;
              $sales-&gt;qty = $quantity[$i];
              $sales-&gt;total = $each_total[$i];
              $sales-&gt;save();
  
              DB::table('items')-&gt;where('id',$item_id[$i])
                  -&gt;update(['qty'=&gt; $items-&gt;qty - $quantity[$i]]);
  
              return view ('show_sales')-&gt;with(array(
                  'name'=&gt;$request-&gt;input('customer_name'),
                  'or_no'=&gt;$request-&gt;input('or_number'),          
                  'total'=&gt;$request-&gt;input('getItemPrice'),            
                  'change'=&gt;$request-&gt;input('change'),
                  'orders'=&gt;$i_name[$i], 
              ));
              $i++;
          } 
      }
  }
  </code></pre>