<?php

namespace App\Exports;

use App\Models\DeviceReportModel;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;

class LaporanKetinggianAirExport implements FromView,ShouldAutoSize 
{
    /**
    * @return \Illuminate\Support\Collection
    */
    public $awal;
    public $akhir;
    public $device;

    public function __construct($awal,$akhir,$device,$nama_device)
{
    $this->awal = $awal;
    $this->akhir = $akhir;
    $this->device = $device;
    $this->nama_device = $nama_device;
}


    public function view(): View
    {
        return view('/content/ketinggian_air/excel', [
            'result' => DeviceReportModel::where("uuid_device",$this->device)->where("status","aktif")->whereBetween('date_report',[$this->awal,$this->akhir])->get(),
            'nama_device'   =>  $this->nama_device,
            'awal'  =>  $this->awal,
            'akhir' =>  $this->akhir,
        ]);
    }
}
