Select::make('product_id')
->live()
->translateLabel()
->options(function(){
return Product::pluck('name','id');
})
->required()
->afterStateUpdated(function(string $state, Set $set){
// Get the selected product
$product = ProductService::fromId($state);
// Generate options for the batch_number select
$optionsForBatchNumberSelect = $product->getWarehouses()->pluck('batch_number','id');
// Set the batch_number select with the generated options
$set('batch_number', $optionsForBatchNumberSelect->toArray());
}),
Select::make('batch_number')
->live();
Select::make('product_id')
->live()
->translateLabel()
->options(function(){
return Product::pluck('name','id');
})
->required()
->afterStateUpdated(function(string $state, Set $set){
// Get the selected product
$product = ProductService::fromId($state);
// Generate options for the batch_number select
$optionsForBatchNumberSelect = $product->getWarehouses()->pluck('batch_number','id');
// Set the batch_number select with the generated options
$set('batch_number', $optionsForBatchNumberSelect->toArray());
}),
Select::make('batch_number')
->live();