<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;

class DealershipBulkUpdateIdsRequest extends FormRequest
{
    public function authorize(): bool
    {
        return Auth::check();
    }

    public function rules(): array
    {
        return [
            'dealership_ids' => ['required', 'array', 'max:100'],
            'dealership_ids.*' => ['required', 'integer', 'exists:dealerships,id'],
        ];
    }

    public function messages(): array
    {
        return [
            'dealership_ids.required' => 'Please select at least one dealership.',
            'dealership_ids.max' => 'You can only update up to 100 dealerships at a time.',
            'dealership_ids.*.exists' => 'One or more selected dealerships do not exist.',
        ];
    }
}
