<?php

namespace App\Http\Requests\Admin\Manage;

use Illuminate\Foundation\Http\FormRequest;

class SaveCourseRegistrationRequest extends FormRequest
{
    public function authorize(): bool
    {
        $student = $this->route('student');

        return $this->user()->hasRole('mahasiswa')
            && $this->user()->student?->id === $student?->id;
    }

    public function rules(): array
    {
        return [
            'course_class_ids' => ['array'],
            'course_class_ids.*' => ['integer'],
            'signature' => ['nullable', 'file', 'image', 'max:2048'],
        ];
    }
}
