title: Import excel data given in each repeated 5 rows to one row in database. Laravel 5.8
body: <p>I've an excel file with following data. The below is the data of 2 users. Each user have 5 rows of details. I need to import the following to 2 rows in database.</p>
  
  <p><a href="https://i.stack.imgur.com/fq8uH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fq8uH.png" alt="excel"></a></p>
  
  <p>The below is my table structure</p>
  
  <p><a href="https://i.stack.imgur.com/Nwv8O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Nwv8O.png" alt="Database table structure"></a></p>
  
  <p>What I need is, I need to import the excel in such a way, in the table there should be only 2 rows like below.</p>
  
  <p><a href="https://i.stack.imgur.com/jAzPr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jAzPr.png" alt="Resut"></a></p>
  
  <p>How can I do this in Laravel 5.8.
  Here is my controller code</p>
  
  <pre><code>public function importMovementFile (Request $request){
  
      $this-&gt;validate($request, [
             'mcafile'  =&gt; 'required|mimes:xls,xlsx,ods'
            ]);
  
      $path = $request-&gt;file('mcafile')-&gt;getRealPath();
  
      $data = \Excel::import(new UsersImport,$path);
  
      return back()-&gt;with('success', 'Excel Data Imported successfully.');
  
  }
  </code></pre>
  
  <p>UserImports</p>
  
  <pre><code>  use Maatwebsite\Excel\Row;
    use Maatwebsite\Excel\Concerns\OnEachRow;
  
    class UsersImport implements OnEachRow
     {
      public function onRow(Row $row)
      {
      $rowIndex = $row-&gt;getIndex();
      $row      = $row-&gt;toArray();
  
     UploadMovAnalysisDataFiles::create([
          'member_name' =&gt; $row[0][$rowIndex],
      ]);
     }
   }
  </code></pre>