input('filters.Plant')); return $form->schema([ // Plant Filter Select::make('Plant') ->options(Plant::pluck('name', 'id')) // Fetch plant names with their IDs ->label('Select Plant') ->reactive() ->afterStateUpdated(function ($state, callable $set) use ($selectedPlant) { session(['selected_plant' => $state]); session()->forget('selected_line'); $set('Plant', $state); $set('Line', null); $this->triggerChartUpdate(); }), // Line Filter Select::make('Line') ->options(function ($get) { $plantId = $get('Plant'); return $plantId ? Plant::find($plantId)->getLineNames()->pluck('name', 'id') : []; }) ->label('Select Line') ->reactive() ->afterStateUpdated(function ($state) { session(['selected_line' => $state]); // Store in session $this->triggerChartUpdate(); // Notify chart to refresh }), ]); } // Helper to check if both filters are set public function triggerChartUpdate(): void { if (session()->has('selected_plant') && session()->has('selected_line')) { $this->dispatch('filtersUpdated'); } } }