<?php

namespace App\Http\Requests;

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

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

    public function rules(): array
    {
        $baseRules = [];
        $currentRoute = Route::currentRouteName();

        $routeSpecificRules = [
            'login' => [
                'username' => ['required', 'min:6', 'string'],
                'password' => ['required', 'min:8', 'string']
            ],
            'refreshOffice' => [
                'fk_site' => ['required', 'min:1', 'integer'],
                'fk_office' => ['required', 'min:1', 'integer']
            ]
        ];

        return array_merge($baseRules, $routeSpecificRules[$currentRoute] ?? []);
    }
}
