<?php

namespace App\Exports;

use Maatwebsite\Excel\Concerns\FromArray;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithTitle;

class ProjectSheet implements FromArray, WithHeadings, WithTitle
{
    protected $projectData;

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

    public function array(): array
    {
        return $this->projectData['issues'];
    }

    public function headings(): array
    {
        return ['summary', 'desc', 'assignee', 'status', 'worklogs', 'originalEstimate', 'timeSpent'];
    }

    public function title(): string
    {
        // Return the project name or any other string based on $projectData
        return $this->projectData['project'];
    }
}
