© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
7 replies
GavTheDev

Use another column in the url for ID

I have a separate panel for sellers and I want to get orders by their reference ('FGIBNTSC02HD') instead of their ID ('123'). Can I set this on Filament level? I know I can set it on model level but that's not what I'm looking for. I just want it for this particular panel.
Solution
@awcodes Turns out it was way easier than I had thought initially (was probably overthinking it). I remembered you can just add the key to the route:

    public static function getPages(): array
    {
        return [
            'index' => Pages\ListOrders::route('/'),
            'create' => Pages\CreateOrder::route('/create'),
            'edit' => Pages\EditOrder::route('/{record:reference}/edit'),
            'details' => Pages\ViewOrderDetails::route('/{record:reference}/details'
        ];
    }
    public static function getPages(): array
    {
        return [
            'index' => Pages\ListOrders::route('/'),
            'create' => Pages\CreateOrder::route('/create'),
            'edit' => Pages\EditOrder::route('/{record:reference}/edit'),
            'details' => Pages\ViewOrderDetails::route('/{record:reference}/details'
        ];
    }

and then override the function that resolves the record:

    protected function resolveRecord(int | string $key): Model
    {
        $record = Order::whereReference($key)->first();

        if ($record === null) {
            throw (new ModelNotFoundException())->setModel($this->getModel(), [$key]);
        }

        return $record;
    }
    protected function resolveRecord(int | string $key): Model
    {
        $record = Order::whereReference($key)->first();

        if ($record === null) {
            throw (new ModelNotFoundException())->setModel($this->getModel(), [$key]);
        }

        return $record;
    }
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Changing the ID in the URL
FilamentFFilament / ❓┊help
2y ago
Handling null id in column url to related resource
FilamentFFilament / ❓┊help
2y ago
searchable in id column
FilamentFFilament / ❓┊help
3y ago
Use value of another column in the same row in a custom table
FilamentFFilament / ❓┊help
2y ago