Changing the ID in the URL
Is it possible to change the ID used in the URL within Filament? I'm using the
spatie/laravel-prefixed-ids
package and want the URL to reflect the prefixed ID and lookup using that instead of the ID column. So if I have an invoice with ID 100, instead of /invoices/100/edit
, I would want the URL to be /invoices/INV100/edit
.
I've reviewed the documentation below, which seems to be close to what I'm looking for, but it doesn't specifically mention if it's possible to change the column used. Any guidance here would be appreciated.
https://filamentphp.com/docs/3.x/panels/resources/getting-started#generating-urls-to-resource-pagesSolution:Jump to solution
Try
protected static ?string $recordRouteKeyName = ‘column_name’;
in your resource. Assuming that is an actual column on your db table.3 Replies
Solution
Try
protected static ?string $recordRouteKeyName = ‘column_name’;
in your resource. Assuming that is an actual column on your db table.That did it! Thank you @awcodes!!
Awesome, be sure to mark it as the solution to help anyone in the future with the same issue.