Forms\Components\Select::make('company_id')
->options(\App\Models\Company::all()->pluck('name', 'id'))
->searchable()
->reactive()
->afterStateUpdated(fn (callable $set) => $set('location_id', null))
Forms\Components\Select::make('location_id')
->label('Location')
->options(function (callable $get) {
$company = \App\Models\Company::find($get('company_id'));
if (! $company) {
return \App\Models\Location::all()->pluck('name', 'id');
}
return $company->locations->pluck('name', 'id');
})
->string()
->searchable()
->required(),
Forms\Components\Select::make('company_id')
->options(\App\Models\Company::all()->pluck('name', 'id'))
->searchable()
->reactive()
->afterStateUpdated(fn (callable $set) => $set('location_id', null))
Forms\Components\Select::make('location_id')
->label('Location')
->options(function (callable $get) {
$company = \App\Models\Company::find($get('company_id'));
if (! $company) {
return \App\Models\Location::all()->pluck('name', 'id');
}
return $company->locations->pluck('name', 'id');
})
->string()
->searchable()
->required(),