How to prevent the select in filter?
The case is I want to select the platform first and get the value and map it in another select. The problem is there is no platform column it just a based on the select type which is in Settings
example if select platform "web". I want to fetch it in the Type select and in there I want to get the key and value
->filters([
Tables\Filters\SelectFilter::make('platform')
->options(Platform::class)
->searchable()
->optionsLimit(10),
Tables\Filters\SelectFilter::make('type')
->options(function ($get) {
$platform = $get('platform');
if (!$platform) {
return [];
}
// Fetch the settings key based on the selected platform
$settingsKey = "{$platform}_report_types";
$reportTypes = Setting::where('key', $settingsKey)->value('value');
if ($reportTypes) {
return collect(json_decode($reportTypes, true))->mapWithKeys(function ($value, $key) {
return [$key => $value]; // Format as [key => value]
})->toArray();
}
return [];
})
->searchable()
->optionsLimit(10),
])
0 Replies