title: Laravel insert database with loop inside
body: <p>I have an array called type.
  In my db i have 4 columns called <code>type_1</code> <code>type_2</code> <code>type_3</code> <code>type_4</code></p>
  
  <p>I am trying with the help of a loop put this at once</p>
  
  <p>Also, I have another problem that is pushing the array to my blade this I will describe in the end!</p>
  
  <p>With no loop it works 
  Example</p>
  
  <pre class="lang-php prettyprint-override"><code>$r            = new PR;
  $r-&gt;type_1    = $type[1];
  $r-&gt;type_2    = $type[2];   
  
  $r-&gt;save();
  </code></pre>
  
  <p>What i have try was:</p>
  
  <pre class="lang-php prettyprint-override"><code>$r = new PR;
  
  foreach ($type as $key =&gt; $value) {
      $r-&gt;type_.$key = $value;
  }
  
  $r-&gt;save();
  </code></pre>
  
  <p>Also i have try this loop on blade  calling {{$r->type_$i}} but doesn't work</p>