IMMREX7
<?php
namespace App\Imports;
use Maatwebsite\Excel\Concerns\ToCollection;
use Illuminate\Support\Collection;
class StudentImport implements ToCollection
{
public $data;
public function collection(Collection $rows)
{
$headers = $rows->first(); // Get the headers from the first row
$data = [];
foreach ($rows->slice(1) as $row) { // Skip headers
$data[] = $headers->combine($row)->toArray(); // Map headers to row values
}
$this->data = $data;
}
public function getData()
{
return $this->data;
}
}
Copyright © 2021 -