<?php

namespace App\Exports;

use App\Models\Applicant;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithStyles;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;

class ApplicantExport implements FromView, ShouldAutoSize, WithStyles
{
    protected $applicant;

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

    public function view(): View
    {
        return view('admin.applicants.excel', [
            'applicant' => $this->applicant
        ]);
    }

    public function styles(Worksheet $sheet)
    {
        return [
            1 => ['font' => ['bold' => true, 'size' => 14]],
            // additional dynamic styling is done in blade, but PhpSpreadsheet will handle most of the inline CSS from blade automatically.
        ];
    }
}
