Forms\Components\Select::make('company_id')
->label('Company')
->options(\App\Models\Company::all()->pluck('name', 'id'))
->reactive()
->afterStateUpdated(function (callable $set) {
$set('product_id', null);
$set('tos_id', null);
})
->searchable()
->required(),
Forms\Components\Select::make('product_id')
->label('Product')
->disabled(fn (callable $get) => !$get('company_id'))
->afterStateUpdated(function (callable $set) {
$set('tos_id', null);
})
->searchable()
->getSearchResultsUsing(fn (string $search, callable $get): array =>
\App\Models\Product::where('company_id', $get('company_id'))
->where('name', 'like', "%{$search}%")
->limit(50)
->pluck('name', 'id')
->toArray())
->required(),
Forms\Components\Select::make('company_id')
->label('Company')
->options(\App\Models\Company::all()->pluck('name', 'id'))
->reactive()
->afterStateUpdated(function (callable $set) {
$set('product_id', null);
$set('tos_id', null);
})
->searchable()
->required(),
Forms\Components\Select::make('product_id')
->label('Product')
->disabled(fn (callable $get) => !$get('company_id'))
->afterStateUpdated(function (callable $set) {
$set('tos_id', null);
})
->searchable()
->getSearchResultsUsing(fn (string $search, callable $get): array =>
\App\Models\Product::where('company_id', $get('company_id'))
->where('name', 'like', "%{$search}%")
->limit(50)
->pluck('name', 'id')
->toArray())
->required(),