Forms\Components\Select::make('attribute_parent_ids')
->label('属性父级')
->options(ProductAttribute::whereNull('parent_id')
->pluck('title', 'id'))
->multiple()
->live(true)
->afterStateUpdated(function (
Forms\Components\Select $component
) {
/** @var Forms\Components\Select $select */
$select = $component->getContainer()
->getComponent('valueIds');
$options = ProductAttribute::whereNotNull('parent_id')
->whereIn('parent_id',
$component->getState())
->pluck('title',
'id');
// remove is cancel options
$newState =
collect($select->getState())
->filter(function ($value) use (
$options
) {
return isset($options[$value]);
})
->toArray();
$select->state($newState)
->options($options);
})
->nullable(),
Forms\Components\Select::make('attribute_ids')
->label('属性')
->options([])
->multiple()
->live(true)
->nullable()
->key('valueIds')
Forms\Components\Select::make('attribute_parent_ids')
->label('属性父级')
->options(ProductAttribute::whereNull('parent_id')
->pluck('title', 'id'))
->multiple()
->live(true)
->afterStateUpdated(function (
Forms\Components\Select $component
) {
/** @var Forms\Components\Select $select */
$select = $component->getContainer()
->getComponent('valueIds');
$options = ProductAttribute::whereNotNull('parent_id')
->whereIn('parent_id',
$component->getState())
->pluck('title',
'id');
// remove is cancel options
$newState =
collect($select->getState())
->filter(function ($value) use (
$options
) {
return isset($options[$value]);
})
->toArray();
$select->state($newState)
->options($options);
})
->nullable(),
Forms\Components\Select::make('attribute_ids')
->label('属性')
->options([])
->multiple()
->live(true)
->nullable()
->key('valueIds')