title: Laravel file upload timing out - adding chunk to updateOrCreate?
body: <p>I'm trying to upload a users csv file and pass the data into a database but because the size of the csv / rows, it keeps timing out. The data must be checked to see if it's already in the database and update or create.</p>
  
  <p>I have applied a chunk to the CSV for reading the data but didn't know if it's possible to add a chunk to the upload to database section? </p>
  
  <p>Here is my function</p>
  
  <pre><code>public function import(Request $request) {
  
      if($request-&gt;file('imported-file')) {
  
          $path = $request-&gt;file('imported-file')-&gt;getRealPath();
  
          $data = Excel::filter('chunk')-&gt;load($path)-&gt;chunk(200, function($results) {
  
              foreach($results as $row) {
  
                  if(!empty($row['postcode'])) {
  
                      $url = "https://maps.googleapis.com/maps/api/geocode/xml?address=".urlencode($row['postcode'])."&amp;region=uk&amp;key=";
                      $tmp = file_get_contents($url);
                      $xml = simplexml_load_string($tmp);
  
                      if((string)$xml-&gt;status == 'OK' &amp;&amp; isset($xml-&gt;result[0])) {
  
                          $lat = 0;
                          $lng = 0;
  
                          if(isset($xml-&gt;result[0]-&gt;geometry-&gt;location-&gt;lat)) {
                              $lat = (string)$xml-&gt;result[0]-&gt;geometry-&gt;location-&gt;lat;
                          }
                          if(isset($xml-&gt;result[0]-&gt;geometry-&gt;location-&gt;lng)) {
                              $lng = (string)$xml-&gt;result[0]-&gt;geometry-&gt;location-&gt;lng;
                          }
  
                      }
  
                      Import::updateOrCreate(
                          [
                              'sitecode' =&gt; $row['sitecode']
                          ],
                          [
                              'sitecode' =&gt; $row['sitecode'],
                              'sitename' =&gt; $row['sitename'],
                              'address_1' =&gt; $row['address_1'],
                              'address_2' =&gt; $row['address_2'],
                              'address_town' =&gt; $row['address_town'],
                              'address_postcode' =&gt; $row['postcode'],
                              'charity' =&gt; $row['charity'],
                              'latitude' =&gt; $lat,
                              'longitude' =&gt; $lng,
                              'approved' =&gt; 1
                          ]
                      );
  
                  } else {
  
                      // Postcode not valid!!!
  
                  }
  
  
              } // endforeach
  
              Session::flash('sucess', 'Import was sucessful.');
              return redirect()-&gt;route('locations');
  
          });
  
      } else {
  
          Session::flash('error', 'Please select a file to upload!');
          return back();
  
      }
  
  }
  </code></pre>