clusters with url parameters to work with specific model data

I currently have a page that's repeated across locations. So you select a location from a drop down menu, and then pages show up for that location to manage data associated with that location. The url would be like myapp.com/team/{team}/location/{location}/config. I currently have a bunch of different forms on the config page and it's getting a bit unwieldy, so I was thinking it would be a good use case for clusters. However, in my config page I receive the Location parameter in the mount method. When I try to set up clusters, I notice that the Cluster class has a mount method that doesn't allow you to pass a parameter. How could I set this up such that I have the 2 route parameters listed above and they'd be passed into my cluster?
1 Reply
Jon Mason
Jon Mason3mo ago
It seems that my cluster "parent" class has to receive my route parameter. I have this:
class ClusterTest extends Cluster
{
protected static ?string $navigationIcon = 'heroicon-o-squares-2x2';

protected static ?string $slug = 'location/{location}/config';

public static function getNavigationLabel(): string
{
return 'Config';
}

public static function getNavigationGroup(): string
{
return SelectedLocation::get()->name ?? '';
}

public static function shouldRegisterNavigation(): bool
{
return SelectedLocation::isSet();
}
}
class ClusterTest extends Cluster
{
protected static ?string $navigationIcon = 'heroicon-o-squares-2x2';

protected static ?string $slug = 'location/{location}/config';

public static function getNavigationLabel(): string
{
return 'Config';
}

public static function getNavigationGroup(): string
{
return SelectedLocation::get()->name ?? '';
}

public static function shouldRegisterNavigation(): bool
{
return SelectedLocation::isSet();
}
}
and I'm getting this error: Missing required parameter for [Route: filament.app.location.{location}.config] [URI: team/{tenant}/location/{location}/config] [Missing parameter: location].