<?php

namespace App\Http\Requests\Finance;

use App\Http\Requests\ApiFormRequest;

class FeeFamilyBalanceRequest extends ApiFormRequest
{
    public function authorize(): bool
    {
        return $this->user() !== null;
    }

    public function rules(): array
    {
        return [
            'parent_id' => ['required', 'integer', 'min:1'],
            'school_year' => ['nullable', 'string', 'max:20'],
            'students' => ['required', 'array', 'min:1'],
            'students.*.student_id' => ['nullable', 'integer', 'min:1'],
            'students.*.firstname' => ['nullable', 'string', 'max:100'],
            'students.*.lastname' => ['nullable', 'string', 'max:100'],
            'students.*.class_section_id' => ['nullable', 'integer', 'min:1'],
            'students.*.grade' => ['nullable', 'string', 'max:20'],
            'students.*.enrollment_status' => ['nullable', 'string', 'max:50'],
            'students.*.admission_status' => ['nullable', 'string', 'max:50'],
            'students.*.discount_amount' => ['nullable', 'numeric', 'min:0'],
        ];
    }
}
