Reset/load fields after select field updated

Hello, i want to make field qty reset or loaded after select field updated.

 Forms\Components\Select::make('inventory_id')
                    ->label('Inventory Name')
                    ->distinct()
                    ->required()
                    ->live()
                    ->options(Inventory::all()->pluck('asset_name', 'id'))
                    ->searchable()
                    ->afterStateUpdated(function (Livewire $livewire) {
                        $livewire->reset('qty');
                    }),

\LaraZeus\Quantity\Components\Quantity::make('qty')
                        ->minValue(1)
                        ->maxValue(function($record){
                            if(!empty($record))
                            $record->inventory->qty-$record->inventory->inventory_location_list->count();
                            else return '1';
                            })
                        ->required(),


I want to get data maxValue qty have relationship from $record that must be selected before
How to achive that?
Thank you!
Solution
Example is a little different than what you're trying to achieve, but the logic is same
Was this page helpful?