<?php

namespace App\Http\Requests;

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

class StoreAreaAdminRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()?->can('create', Area::class) ?? false;
    }

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