title: Laravel 5.2 Insert from select using dynamic content
body: <p>As a novice to laravel I am hoping I can get to the bottom of this rather irritating issue!</p>
  
  <p>I have a small app that consists of 2 user types, Buyers and Providers, The usertype->buyers can request a free estimation for a service they require and the provider can create this manually or have an estimation sent automatically based on what they set as there default value for that specific price range so for example if a user(buyer) requests an estimation for a service that is £200 the provider may have set a default estimation of £180 - £220 for that price range and this is what will be shown to the user.</p>
  
  <p>The problem I have is to make it fair we use the random function within laravel to randomly select 5 providers from the providers_table along with their default estimation and show this to the user from orderBy in descending order and looping through the results in the view.</p>
  
  <pre><code>$projectbids = ProjectBids::where('provider_id', '=', $proid)
      -&gt;where('category_id', '=', $catid)
      -&gt;orderBy('bid_price', 'desc')
      -&gt;get()-&gt;random(5);
  
  foreach($projectbids as $bid)
  {{ $bid-&gt;bid_price }}
  endforeach
  </code></pre>
  
  <p>So I'm trying to find a way to insert the 5 displayed estimations into a saved_estimates table so if the user refreshes the page or comes back to the page the model and view will not reorder the providers results based from the random(5) function that gets called.</p>
  
  <p>I'm aware of this question:  <a href="https://stackoverflow.com/questions/25533608/create-a-insert-select-statement-in-laravel">Create a Insert... Select statement in Laravel</a> but wasn't to sure if there could be a better or easier way of doing this as my problem lays where I'm looping through the 5 results provided to the view from the table.</p>
  
  <p>In a nutshell:  I want to be able to store the 5 dynamic results straight into a saved_estimations table with several columns such as project_id, provider_id, user_id, estimated_price so the user can come back to their saved estimations in the future without them changing.</p>
  
  <p>Very grateful for any input and advice, it will be very helpful to see what the more experienced users would suggest.</p>
  
  <p>Thanks</p>
  
  <p>-- Updated personal approach to see if there is room for improvement and to make it more laravel friendly.</p>
  
  <pre><code>    $results = $bidders;
      foreach($results as $row){
          $project = $projectid;
          $category = $row-&gt;category_id;
          $provider = $row-&gt;service_providers_id;
          $bidprice = $row-&gt;bid_price;
          $propvalue = $row-&gt;property_value_id;
  
          DB::table('static_bids')-&gt;insert(array(
              'project_id' =&gt; $project,
              'category_id' =&gt; $category,
              'service_providers_id' =&gt; $provider,
              'bid_price' =&gt; $bidprice,
              'property_value_id' =&gt; $propvalue
          ));
        }
  </code></pre>