<?php

namespace App\Http\Requests\Audit;

use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;

class AuditLogFilterRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            /** Filter berdasarkan nama modul audit. */
            'module' => [
                'nullable',
                'string',
                'max:100',
            ],

            /** Filter berdasarkan nama action audit. */
            'action' => [
                'nullable',
                'string',
                'max:100',
            ],

            /** Filter berdasarkan ID user pelaku. */
            'user_id' => [
                'nullable',
                'integer',
                'exists:users,id',
            ],

            /** Filter berdasarkan ID tenant. */
            'tenant_id' => [
                'nullable',
                'integer',
                'exists:tenants,id',
            ],

            /** Nomor halaman yang ingin diambil. */
            'page' => [
                'nullable',
                'integer',
                'min:1',
            ],

            /** Jumlah data per halaman, maksimal 100. */
            'per_page' => [
                'nullable',
                'integer',
                'min:1',
                'max:100',
            ],
        ];
    }
}
