<?php

namespace App\Http\Resources\Scores;

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

class ScorePredictorStudentResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'student_id' => (int) ($this->resource['student_id'] ?? 0),
            'school_id' => $this->resource['school_id'] ?? null,
            'firstname' => $this->resource['firstname'] ?? null,
            'lastname' => $this->resource['lastname'] ?? null,
            'class_section_id' => $this->resource['class_section_id'] ?? null,
            'fall_score' => $this->resource['fall_score'] ?? null,
            'spring_score' => $this->resource['spring_score'] ?? null,
            'final_average' => $this->resource['final_average'] ?? null,
            'required_spring_score' => $this->resource['required_spring_score'] ?? null,
            'winning_risk' => $this->resource['winning_risk'] ?? null,
            'required_spring_to_pass' => $this->resource['required_spring_to_pass'] ?? null,
            'failure_risk' => $this->resource['failure_risk'] ?? null,
            'status' => $this->resource['status'] ?? null,
            'trophy_awarded' => (bool) ($this->resource['trophy_awarded'] ?? false),
            'trophy_reason' => $this->resource['trophy_reason'] ?? null,
        ];
    }
}
