<?php

namespace App\Http\Requests\Admin\AcademicClasses;

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

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

    public function rules(): array
    {
        return [
            'course_class_id' => ['required', 'integer', Rule::exists('course_classes', 'id')],
            'title' => ['required', 'string', 'max:150'],
            'description' => ['nullable', 'string'],
            'meeting_number' => ['nullable', 'integer', 'min:1'],
            'file' => [
                'nullable',
                'file',
                'max:10240',
                'mimes:pdf,doc,docx,ppt,pptx,xls,xlsx,jpg,jpeg,png,mp4,zip',
            ],
        ];
    }
}
