title: Save data in db from excel in laravel
body: <p>I need to import excel data in db. but is giving me tough time.
  here is my controller function</p>
  
  <pre><code>      $path = Input::file('import_file')-&gt;getRealPath();
          $data = \Excel::load($path)-&gt;get();
  
          if($data-&gt;count()){
              foreach ($data as $key =&gt; $value) {
                  $arr[] = ['product_id' =&gt; $value-&gt;price, 'details' =&gt; 
                  $value-&gt;stock];
  
              }
  
  
              if(!empty($arr)){
                  \DB::table('stock')-&gt;insert($arr);
                  dd('Insert Record successfully.');
              }
          }
  </code></pre>
  
  <p>where price and stock is fields in excel.
  below is the error</p>
  
  <pre><code>          Property [price] does not exist on this collection instance.
  </code></pre>
  
  <p>here is dd() of my controller function when i am trying to save excel data in db.</p>
  
  <pre><code>          SheetCollection {#375 ▼
          #title: ""
           #items: array:3 [▼
        0 =&gt; RowCollection {#498 ▼
    #heading: array:2 [▼
      0 =&gt; "stock"
      1 =&gt; "price"
    ]
    #title: "Sheet1"
    #items: array:3 [▼
      0 =&gt; CellCollection {#462 ▼
        #title: null
        #items: array:2 [▼
          "stock" =&gt; 2.0
          "price" =&gt; 3.0
        ]
      }
      1 =&gt; CellCollection {#481 ▼
        #title: null
        #items: array:2 [▼
          "stock" =&gt; 3.0
          "price" =&gt; 2.0
        ]
      }
      2 =&gt; CellCollection {#480 ▼
        #title: null
        #items: array:2 [▶]
      }
    ]
  }
  1 =&gt; RowCollection {#533 ▶}
  </code></pre>