<?php

namespace App\Http\Requests;

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

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

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

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