Filter enum value from select enum options (get all enum values but selected ones)

Hey everyone, I have a repeater for some attributes of same table, to be able to store multiple data using handleRecordCreation method one of the repeated attribute is car_type which is a select options using CarType::class enum, so I don't want to display an option that I already used in a previous repeater, do you know how I achieve that?
Forms\Components\Select::make('car_type')
->translateLabel()
->enum(CarType::class)
// ->options(CarType::class)
->options(function (Forms\Get $get) {
$carType = $get('car_type');
info($carType);
//remove $carType from returned CarType::class
return CarType::class;
})
->live()
Forms\Components\Select::make('car_type')
->translateLabel()
->enum(CarType::class)
// ->options(CarType::class)
->options(function (Forms\Get $get) {
$carType = $get('car_type');
info($carType);
//remove $carType from returned CarType::class
return CarType::class;
})
->live()
Thanks in advance!
No description
3 Replies
Jellibloom
JellibloomOP9mo ago
I have tried doing this but didn't work
->options(function (Forms\Get $get) {
return collect(CarType::cases())->where('name', '!=', $get('car_type'))->pluck('name', 'value')->toArray();
})
->options(function (Forms\Get $get) {
return collect(CarType::cases())->where('name', '!=', $get('car_type'))->pluck('name', 'value')->toArray();
})
Jellibloom
JellibloomOP9mo ago
Thanks a lot @Leandro Ferreira , didn't know that!
Want results from more Discord servers?
Add your server