<?php

namespace App\Http\Resources\Admin\Progress;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class ProgressGroupResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        $reports = $this['reports'] ?? [];

        return [
            'week_start' => $this['week_start'] ?? null,
            'week_end' => $this['week_end'] ?? null,
            'class_section_id' => $this['class_section_id'] ?? null,
            'class_section_name' => $this['class_section_name'] ?? '',
            'reports' => $reports, // keyed by subject for compatibility
        ];
    }
}