<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'from' => ['nullable', 'date'],
            'to' => ['nullable', 'date'],
            'action' => ['nullable', 'string', 'max:255'],
            'actions' => ['nullable', 'array'],
            'actions.*' => ['string', 'max:255'],
            'user_id' => ['nullable', 'integer', 'exists:users,id'],
            'user_ids' => ['nullable', 'array'],
            'user_ids.*' => ['integer', 'exists:users,id'],
            'server_resource_id' => ['nullable', 'integer', 'exists:server_resources,id'],
            'server_resource_ids' => ['nullable', 'array'],
            'server_resource_ids.*' => ['integer', 'exists:server_resources,id'],
            'protocol' => ['nullable', 'string', 'in:SSH,SFTP,RDP'],
            'sort_by' => ['nullable', 'string', 'in:id,requested_at,action,protocol,user,resource,account'],
            'sort_order' => ['nullable', 'string', 'in:asc,desc'],
            'per_page' => ['nullable', 'integer', 'min:1', 'max:100'],
        ];
    }
}
