F
Filament•12mo ago
Daniel Plomp

Self-Healing URL's

I use this package to implement 'self-healing urls': https://github.com/lukeraymonddowning/self-healing-urls It functions great and fulfills my website's requirements. One modification I made was to use an alternative ID instead of Laravel's default primaryKey. To accomplish this, I implemented an override:
public function getRouteKeyName(): string
{
return 'public_id';
}
public function getRouteKeyName(): string
{
return 'public_id';
}
In the frontend, everything functions perfectly. The system effectively resolves my models in both directions and automatically corrects URLs. However, I encounter issues in the backend. Although the new URL is visible in my table, clicking on it results in a 404 error. Consequently, navigation to pages such as the edit page is unsuccessful. I am not sure about the next steps to address this issue. My assumption was that Filament adheres to the routing system, but it seems the package might be operating differently. Maybe someone has an idea on to resolve this?
GitHub
GitHub - lukeraymonddowning/self-healing-urls: A Laravel package th...
A Laravel package that allows you to define self-healing URLs for Eloquent models - GitHub - lukeraymonddowning/self-healing-urls: A Laravel package that allows you to define self-healing URLs for ...
8 Replies
ChesterS
ChesterS•12mo ago
Try adding this to the resource file
protected static ?string $recordRouteKeyName = 'public_id';
protected static ?string $recordRouteKeyName = 'public_id';
Daniel Plomp
Daniel PlompOP•12mo ago
Yes, already tried it, but no luck 🤔
ChesterS
ChesterS•12mo ago
What exactly is the issue? The links use the correct ID but when you click on them filament doesn't find them and returns a 404? Is the query that is executed correct?
awcodes
awcodes•12mo ago
Sounds like you need a way in the self healing URLs to exclude the panel’s path. I really don’t see the use in the context of the admin / panel / crud context.
ChesterS
ChesterS•12mo ago
Is there a way to have both? I wanted to use UUIDs for the public facing panels and numeric IDs for admin panels, but I couldn't find a way to do that. I had to use the same for both (UUID) because I needed to override the getRouteKeyName method
awcodes
awcodes•12mo ago
Honestly, I don’t know, but I would hope that the healing URLs package has a way to disable its middleware for specific routes.
Daniel Plomp
Daniel PlompOP•12mo ago
Thanks. I will see if something like that is possible. OK, if I make these changes it works: In my Resource I added: protected static ?string $recordRouteKeyName = 'id'; In the getPages function I changed the edit method to this: 'edit' => Pages\EditModel::route('/{record:id}/edit'), So now it handles both scenarios. 🙂
SLINZEN
SLINZEN•9mo ago
doesnt work with the current version?
Want results from more Discord servers?
Add your server