re-render sidebar when item is selected

I'm probably doing this wrong by putting it in the boot method, but I have a dropdown in the topbar that sets a value in the session. Whenever that changes, or is cleared, I want the sidebar to refresh.

I'm doing this in the boot menu, which is likely not right as it's only running once, but I tried adding a render method and didn't make a difference.

    protected $selectedLocationId = false;
    protected $selectedLocationName = false;

    public function boot()
    {
             $selectedLocation = Session::get('selectedLocation');
            if (!empty($selectedLocation)) {
                $this->selectedLocationId = $selectedLocation->id;
                $this->selectedLocationName = $selectedLocation->name;
            }
    }


And then I'm trying to add this navigation that should change based on the selection:

->navigationGroups([
                NavigationGroup::make()
                    ->label(function () {
                        return $this->selectedLocationName;
                    })
                    ->collapsed()
            ])
            ->navigationItems([
                NavigationItem::make('details')
                    ->label('Details')
                    ->visible($this->selectedLocationId ?? false)
                    ->url(function () {
                        if ($this->selectedLocationId) {
                            return LocationResource::getUrl('details', ['record' => $this->selectedLocationId]);
                        } else {
                            return false;
                        }
                    }),


Also, I have database notifications enabled, so I see the update in the network tab in dev tools happening every few seconds or so, but when I do a Log::debug() from the boot method, it puts log entries like multiple times a second. I don't know why the boot method would be getting called that frequently, but I have been noticing recently that my log file is too big to view.
Was this page helpful?