<?php

namespace App\Exports;

use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\WithTitle;

class ReporteExport implements FromView, WithTitle
{

    public function setData($data)
    {
        $this->data = $data;
        return $this;
    }

    
    public function setTipo($tipo)
    {
        $this->tipoR = $tipo;
        return $this;
    }

    public function view(): View
    {
        if ($this->tipoR == 1) {
            return view('exports.reporteExcel', ['rads' => $this->data]);
        } else if ($this->tipoR == 2) {
            return view('exports.consolidadoExcelDeps', ['deps' => $this->data]);
        }
        else if ($this->tipoR == 3) {
            return view('exports.consolidadoExcelEstados', ['estado' => $this->data]);
        }
        else if ($this->tipoR == 4) {
            return view('exports.consolidadoExcelTipos', ['tipo' => $this->data]);
        }

    }

    public function title(): string
    {
        if ($this->tipoR == 1) {
            return 'Detallado';
        }

        if ($this->tipoR == 2) {
            return 'Dependencias';
        }

        if ($this->tipoR == 3) {
            return 'Estados';
        }

        if ($this->tipoR == 4) {
            return 'Por Tipos';
        }
    }

}
