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

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

class ZonesExport implements FromCollection, WithHeadings
{
	public $zones;

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

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