<?php

namespace App\Http\Requests;

use App\Models\Area;
use Illuminate\Foundation\Http\FormRequest;

class UpdateAreaAdminRequest extends FormRequest
{
    public function authorize(): bool
    {
        /** @var Area $area */
        $area = $this->route('area');

        return $this->user()?->can('update', $area) ?? false;
    }

    public function rules(): array
    {
        return [
            'name' => ['sometimes', 'string', 'max:255'],
            'sort_order' => ['sometimes', 'integer', 'min:0'],
            'is_active' => ['sometimes', 'boolean'],
            'requires_scan_twice' => ['sometimes', 'boolean'],
            'floor_label' => ['nullable', 'string', 'max:32'],
            'is_enabled' => ['sometimes', 'boolean'],
        ];
    }
}
