<?php

namespace App\Filament\Resources\Master\SubLocations\Schemas;

use App\Models\Location;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Schema;

class SubLocationForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->components([
                Select::make('location_id')
                    ->label('Lokus Utama')
                    ->options(Location::query()->pluck('name', 'id'))
                    ->searchable()
                    ->native(false)
                    ->required()
                    ->rules(['exists:locations,id'])
                    ->autofocus(),

                TextInput::make('name')
                    ->label('Nama Sublokus')
                    ->placeholder('Kecamatan Purwakarta')
                    ->autocomplete(false)
                    ->required()
                    ->maxLength(50),
            ])
            ->columns(1);
    }
}
