Customizing route parameter names and urls

I have an EditREcord resource that I'd like to have accept a parameter, location, but it only seems to want to accept a parameter called record. In my main Resource class I have this:
public static function getPages(): array
{
return [
'index' => Pages\ListLocations::route('/'),
'edit' => Pages\EditLocation::route('/{location}/edit'),
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListLocations::route('/'),
'edit' => Pages\EditLocation::route('/{location}/edit'),
];
}
and then in my EditLocation class I've done essentially copied the mount method from the EditRecord class so that I can pass in a variable named $location.
public function mount(int | string $location): void
{
$this->record = $this->resolveRecord($location);

$this->authorizeAccess();

$this->fillForm();

$this->previousUrl = url()->previous();
}
public function mount(int | string $location): void
{
$this->record = $this->resolveRecord($location);

$this->authorizeAccess();

$this->fillForm();

$this->previousUrl = url()->previous();
}
I'm sure this isn't right to begin with, hopefully someone can clue me in on the right way to do this. I'm getting the error: Missing required parameter for [Route: filament.app.resources.locations.edit] [URI: team/{tenant}/locations/{location}/edit] [Missing parameter: location].
5 Replies
Hasnain Haider
Hasnain Haider13mo ago
Following.... facing the same issue
Jon Mason
Jon MasonOP13mo ago
bump
sixteensquared
sixteensquared12mo ago
Same issue here. Have you found a solution?
Jon Mason
Jon MasonOP12mo ago
no I haven't been able to resolve it.
DrByte
DrByte12mo ago
I don't have a complete answer, but ... I wonder if you might have to override the routes() method on the page, for it to recognize the additional named parameters? https://github.com/filamentphp/filament/blob/941919e8ff96129c96caa5c8db9f9cc3b89c2bf7/packages/panels/src/Pages/Concerns/HasRoutes.php#L23-L38
GitHub
filament/packages/panels/src/Pages/Concerns/HasRoutes.php at 941919...
A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS. - filamentphp/filament
Want results from more Discord servers?
Add your server