<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class StoreWhatWeDoImageRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()?->can('manage what we do images') ?? false;
    }

    public function rules(): array
    {
        return [
            'image' => ['required', 'image', 'mimes:jpeg,png,webp', 'max:2048'],
            'slot'  => ['required', 'integer', 'between:1,9'],
        ];
    }

    public function messages(): array
    {
        return [
            'image.mimes' => 'The image must be a JPEG, PNG, or WebP file.',
            'image.max'   => 'The image must not exceed 2MB.',
            'slot.between' => 'The slot must be between 1 and 9.',
        ];
    }
}
