<?php

namespace App\Http\Requests;

use App\Rules\HostOrIpAddress;
use Illuminate\Foundation\Http\FormRequest;

class StoreMikrotikRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()?->can('mikrotik.create');
    }

    public function rules(): array
    {
        return [
            'name' => ['required', 'string', 'max:255'],
            'ip_address' => ['required', new HostOrIpAddress],
            'api_port' => ['required', 'integer', 'min:1', 'max:65535'],
            'username' => ['required', 'string', 'max:255'],
            'password' => ['required', 'string', 'max:255'],
            'ssl_enabled' => ['required', 'boolean'],
            'is_default' => ['sometimes', 'boolean'],
            'status' => ['required', 'boolean'],
            'remarks' => ['nullable', 'string', 'max:1000'],
        ];
    }
}
