F
Filament11mo ago
Oddman

How do you handle models with custom route keys?

I have articles, their route key is a slug column - I can't see anywhere in the filament docs how to handle this. I'm fine if filament wants to fetch models based on their id, rather than the slug - but it trips over itself:
SELECT
*
FROM
"articles"
WHERE
"id" = getting - acquainted - WITH - brevant
limit
1
SELECT
*
FROM
"articles"
WHERE
"id" = getting - acquainted - WITH - brevant
limit
1
How is this meant to be handled?
3 Replies
Oddman
OddmanOP11mo ago
Actually, all good - decided to disable the routeKey and instead just handle it manually, as I was going to do that for route model binding anyway.
DrByte
DrByte11mo ago
Right: Filament depends on you configuring your app to use Laravel conventions for route-model-binding. While there are ways to modify various queries at various points, it gets super complicated to do that if you're not using Laravel's standard approaches and then want Filament to do things with nested relationships or filters or sorts or searches.
Oddman
OddmanOP11mo ago
Yeah I've found a few cases where laravel conventions get in my way. It's rare, however.
Want results from more Discord servers?
Add your server