<?php

namespace App\Exports;

use App\Models\Guru;
use Maatwebsite\Excel\Concerns\FromArray;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithHeadings;

class GuruExport implements FromArray, WithHeadings, ShouldAutoSize
{

    public function array(): array
    {
        $guru = Guru::all();

        $guru_filter = [];

        $no = 1;
        for ($i = 0; $i < $guru->count(); $i++) {
            $guru_filter[$i]['no'] = $no++;
            $guru_filter[$i]['nip'] = $guru[$i]->nip;
            $guru_filter[$i]['nama_guru'] = $guru[$i]->nama_guru;
            $guru_filter[$i]['jabatan'] = $guru[$i]->jabatan;
            $guru_filter[$i]['jenis_kelamin'] = $guru[$i]->jenis_kelamin;
        }

        return $guru_filter;
    }
    public function headings(): array
    {
        return [
            'No',
            'Nip',
            'Nama Guru',
            'Jabatan',
            'Jenis Kelamin',
        ];
    }
}