<?php
namespace App\Exports;
use App\Models\SubCounty;

use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use DB;

class SubCountiesExport implements FromCollection, WithHeadings
{
	public $subcounties;

    public function __construct($subcounties) {
        $this->subcounties = $subcounties;
    }

    public function collection()
    {
        $subcounties=SubCounty::query()
						->whereIn('SubCountyID', $this->subcounties)
						->select('SubCountyID','SubCountyName','CreatedAt')
						->get();
						
		return $subcounties;
    }
	
	public function headings(): array
    {
        //return ["heading_1", "heading_2", "heading_3"];
		return array_keys($this->collection()->first()->toArray());
    }
}