<?php

namespace App\Http\Resources\Admin;

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

class TeacherSubmissionReportResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'semester' => $this['semester'] ?? '',
            'school_year' => $this['school_year'] ?? '',
            'rows' => TeacherSubmissionRowResource::collection(collect($this['rows'] ?? [])),
            'notification_history' => $this['notification_history'] ?? [],
            'summary' => [
                'total_items' => data_get($this->resource, 'summary.total_items', 0),
                'missing_items' => data_get($this->resource, 'summary.missing_items', 0),
                'submitted_items' => data_get($this->resource, 'summary.submitted_items', 0),
                'submission_percentage' => data_get($this->resource, 'summary.submission_percentage', 0),
            ],
        ];
    }
}