Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to override the route key name in resource #15252

Closed
Barbapapazes opened this issue Jan 5, 2025 · 1 comment
Closed

Unable to override the route key name in resource #15252

Barbapapazes opened this issue Jan 5, 2025 · 1 comment
Labels

Comments

@Barbapapazes
Copy link

Package

filament/filament

Package Version

3.0

Laravel Version

11.0

Livewire Version

/

PHP Version

8.3

Problem description

Unable to override the route key name from a model inside a resource.

Expected behavior

I would like to override the default route key name, provided by getRouteKeyName function in a model.

I have an application where the default route key name is a column named meta_id. It works well and because I have a lot of routes, it's a good default. I have two routes that overrides this using

 Route::post('posts/{post:id}/votes', [Controller::class, '...']);

As you can see, I use the syntax model:column to change the behavior.

With filament, I expected to be able to reproduce this with this:

public static function getPages(): array
    {
        return [
            'view' => Pages\ViewPost::route('/{record:id}'),
        ];
    }

With the same syntax. This does not works (this change the way the URL is built but not how the model is resolved).

Is there a way to make it works?

Steps to reproduce

See the reproduction: Barbapapazes/demo@3461be2

Reproduction repository (issue will be closed if this is not valid)

Barbapapazes/demo@3461be2

Relevant log output

No response

@Barbapapazes
Copy link
Author

Using this attribute protected static ?string $recordRouteKeyName = 'id' with the updated route(/{record:id})`

@github-project-automation github-project-automation bot moved this from Todo to Done in Roadmap Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

No branches or pull requests

1 participant