Help with sidebar

Trying to create a custom section in the sidebar. The navigation group is showing up, but the page underneath the group isn't showing up. I'm just doing it with one page right now to try and get it working. Here's the livewire component:
class LocationSidebar extends Component
{
public ?string $label = null;
public bool $collapsible = true;
public ?string $icon = null;
public bool $visible = false;
public ?int $selectedLocationId = null;
public $url = null;


public function render()
{
$selectedLocation = Session::get('selectedLocation');


if (!empty($selectedLocation)) {
$this->label = $selectedLocation->name;
$this->selectedLocationId = $selectedLocation->id;
$this->visible = true;
$this->url = LocationResource::getUrl('vendors', ['record' => $selectedLocation->id]);
}

return view('livewire.components.location-sidebar');
}
}
class LocationSidebar extends Component
{
public ?string $label = null;
public bool $collapsible = true;
public ?string $icon = null;
public bool $visible = false;
public ?int $selectedLocationId = null;
public $url = null;


public function render()
{
$selectedLocation = Session::get('selectedLocation');


if (!empty($selectedLocation)) {
$this->label = $selectedLocation->name;
$this->selectedLocationId = $selectedLocation->id;
$this->visible = true;
$this->url = LocationResource::getUrl('vendors', ['record' => $selectedLocation->id]);
}

return view('livewire.components.location-sidebar');
}
}
and in the view I have this:
<x-filament-panels::sidebar.group :label="$label" :icon="$icon" :collapsible="$collapsible">

<x-filament-panels::sidebar.item url="{{ $url }}" />

</x-filament-panels::sidebar.group>
<x-filament-panels::sidebar.group :label="$label" :icon="$icon" :collapsible="$collapsible">

<x-filament-panels::sidebar.item url="{{ $url }}" />

</x-filament-panels::sidebar.group>
I've created the page, and registered in my LocationResource class as a page:
public static function getPages(): array
{
return [
'index' => Pages\ListLocations::route('/'),
'create' => Pages\CreateLocation::route('/create'),
'edit' => Pages\EditLocation::route('/{record}/edit'),
'view' => Pages\ViewLocation::route('/{record}'),
'vendors' => Pages\Vendors::route('/{record}/vendors'),
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListLocations::route('/'),
'create' => Pages\CreateLocation::route('/create'),
'edit' => Pages\EditLocation::route('/{record}/edit'),
'view' => Pages\ViewLocation::route('/{record}'),
'vendors' => Pages\Vendors::route('/{record}/vendors'),
];
}
As you can see in the screenshot, the title of the navigation group is there, so the session variable is getting pulled correctly, but the navigation item is just not showing up.
No description
1 Reply
Jon Mason
Jon MasonOP15mo ago
Ideally I think I need to generate an array of NavigationItems, as this would be one of a handful of pages that need to be in this section. But I was initially just focused on getting this to work as a proof of concept. I was able to add an array of NavigationItems like this:
$items[] = NavigationItem::make('Vendors')
->icon('heroicon-o-home')
->group($selectedLocation->name)
->url(LocationResource::getUrl('vendors', ['record' => $selectedLocation->id]));
$items[] = NavigationItem::make('Vendors')
->icon('heroicon-o-home')
->group($selectedLocation->name)
->url(LocationResource::getUrl('vendors', ['record' => $selectedLocation->id]));
But for some reason only the navigation group is displaying, the item itself doesn't show up.. I can dd the item and see that it's there and everything looks correct. What am I missing?
Want results from more Discord servers?
Add your server