<?php

namespace App\Http\Requests\Finance;

use App\Http\Requests\ApiFormRequest;

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

    public function rules(): array
    {
        return [
            'parent_id' => ['required', 'integer', 'min:1'],
            'student_id' => ['required', 'integer', 'min:1'],
            'event_id' => ['nullable', 'integer', 'min:1'],
            'event_name' => ['required_without:event_id', 'nullable', 'string', 'max:255'],
            'amount' => ['nullable', 'numeric', 'min:0'],
            'description' => ['nullable', 'string', 'max:2000'],
            'school_year' => ['nullable', 'string', 'max:20'],
            'semester' => ['nullable', 'string', 'max:20'],
        ];
    }
}
