IMMREX7

aku nok ndi : /home/spdtg/www/schoolmis/app/Imports/
File Up :
aku nok ndi : /home/spdtg/www/schoolmis/app/Imports/StudentImport.php

<?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 - 2025 IMMREX7