<?php

namespace App\Http\Requests\Unit;

use Illuminate\Foundation\Http\FormRequest;

class StoreUnitRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()->isAdmin();
    }

    public function rules(): array
    {
        return [
            'unit_name' => ['required', 'string', 'max:100'],
            'unit_code' => ['required', 'string', 'max:100', 'unique:units,unit_code'],
            'location'  => ['nullable', 'string', 'max:255'],
            'status'    => ['sometimes', 'in:active,inactive'],
            'notes'     => ['nullable', 'string'],
        ];
    }
}
