<?php

namespace App\Http\Requests\Admin\Services;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class AcademicAdvisingLogRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()->can($this->isMethod('post') ? 'create-academic-advising-logs' : 'update-academic-advising-logs');
    }

    public function rules(): array
    {
        return [
            'student_ids' => ['required', 'array', 'min:1'],
            'student_ids.*' => ['integer', Rule::exists('students', 'id')],
            'lecturer_id' => ['required', 'integer', Rule::exists('lecturers', 'id')],
            'topic' => ['required', 'string', 'max:150'],
            'notes' => ['nullable', 'string'],
        ];
    }
}
