xxxxxxxxxx
Select::make('country_id')
->label('Country')
->options(Country::all()->pluck('name', 'id')->toArray())
->reactive()
->afterStateUpdated(function(callable $set) {
$set('state_id', null);
}),
Select::make('state_id')
->label('State')
->options(function (callable $get) {
$country = Country::find($get('country_id'));
if (!$country) {
return State::all()->pluck('name', 'id');
}
return $country->states->pluck('name', 'id');
}),