<?php

namespace App\Exports;

use App\Models\Siswa;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;

class StudentExport implements FromCollection, WithHeadings
{
    /**
     * @return \Illuminate\Support\Collection
     */
    public function collection()
    {
        return Siswa::join("users", "users.id", "=", "siswa.user_id")->get(["siswa.id", "siswa.nama", "siswa.nik", "siswa.tgl_lahir", "siswa.jenkel", "siswa.agama", "siswa.jenjang", "siswa.alamat", "siswa.nama_ortu", "siswa.no_telp", "siswa.kerja_ortu", "siswa.level"]);
    }

    public function headings(): array
    {
        return [
            '#',
            'NAMA',
            'NIK',
            'TANGGAL LAHIR',
            'JENIS KELAMIN',
            'AGAMA',
            'JENJANG',
            'ALAMAT',
            'NAMA ORTU',
            'NO. HP',
            'PEKERJAAN ORTU',
            'KELAS'
        ];
    }
}
