title: Laravel, save data from array to database
body: <p>I need to save data from this array to MySQL database</p>
  
  <pre><code>0 =&gt; {#517 ▼
      +"id": 59
      +"name": "example_name_1"
      +"category": "category_1"
      +"price": 100
      +"description": "example_description_1"
  }
  1 =&gt; {#516 ▼
      +"id": 60
      +"name": "example_name_2"
      +"category": "category_2"
      +"price": 200
      +"description": "example_description_2"
  }
  </code></pre>
  
  <p>I am tryinig to save like this, but reveive errors like </p>
  
  <blockquote>
    <p>Undefined index: name</p>
  </blockquote>
  
  <pre><code>for ($idx = 0; $idx &lt; count($products); $idx++)
  {
      $values = new Product();
      $values-&gt;name = $products["name"][$idx];
      $values-&gt;category= $products["category"][$idx];
      $values-&gt;description = $products['description'][$idx];
      $values-&gt;price = $products['price'][$idx];
      $values-&gt;save();
  }
  </code></pre>