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:
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);
}),