<?php

namespace App\Http\Requests\Admin;

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

class ExerciseRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'name' => ['required', 'string', 'max:150'],
            'name_en' => ['nullable', 'string', 'max:150'],
            'main_muscle_id' => ['nullable', 'integer', 'exists:muscles,id'],
            'difficulty' => ['required', Rule::in(['beginner', 'intermediate', 'advanced'])],
            'description' => ['nullable', 'string', 'max:2000'],
            'is_active' => ['sometimes', 'boolean'],

            'muscle_ids' => ['nullable', 'array'],
            'muscle_ids.*' => ['integer', 'exists:muscles,id'],
            'equipment_ids' => ['nullable', 'array'],
            'equipment_ids.*' => ['integer', 'exists:equipment,id'],

            'gif' => ['nullable', 'file', 'mimes:gif', 'max:6144'],
            'image' => ['nullable', 'image', 'max:2048'],
        ];
    }

    public function messages(): array
    {
        return [
            'name.required' => 'نام حرکت الزامی است.',
            'difficulty.required' => 'سطح سختی را انتخاب کنید.',
            'gif.mimes' => 'فایل GIF باید فرمت gif داشته باشد.',
        ];
    }
}
