<?php

namespace App\Http\Requests\Security;

use App\Http\Requests\ApiFormRequest;

class IpBanIndexRequest extends ApiFormRequest
{
    public function authorize(): bool
    {
        return $this->user() !== null || auth()->user() !== null;
    }

    public function rules(): array
    {
        return [
            'status' => ['nullable', 'string', 'in:all,active'],
            'search' => ['nullable', 'string', 'max:100'],
            'sort_by' => ['nullable', 'string', 'in:updated_at,blocked_until,attempts,ip_address,last_attempt_at'],
            'sort_dir' => ['nullable', 'string', 'in:asc,desc'],
            'page' => ['nullable', 'integer', 'min:1'],
            'per_page' => ['nullable', 'integer', 'min:1', 'max:200'],
        ];
    }
}
