FilamentF
Filament3y ago
Eth

retrieving previous record

I’m trying to get the price for the chosen place name but it’s retrieving the previous price -giving null for the first record-

Code:

Forms\Components\Select::make('placeName')
                ->label('Place Name')
                ->required()
                ->live()
                ->searchable()
                ->options(Place::all()->pluck('placeName'))
                ->afterStateUpdated(function ($state, callable $set, callable $get){
                        $place = $get('placeName');
                        $placePrice = Place::find($place)->placePrice;
                        $set('totalPrice', $placePrice);
                    }),
IMG_2552.jpg
IMG_2553.jpg
IMG_2554.jpg
Was this page helpful?