F
Filament12mo 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);
}),
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);
}),
No description
No description
No description
2 Replies
KA
KA12mo ago
try ->options(Place::all()->pluck('placeName', 'id'))
Eth
EthOP12mo ago
This is it!, thank you
Want results from more Discord servers?
Add your server