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:Jump to 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:
```php
public static function getPages(): array
{...
4 Replies
Wouldn’t this be a relationship on the model and not a panel thing. Why would the panel matter to the results of the query/relationship outside of tenancy?
Sorry, I'm not sure if I follow 😅 . I'm talking about retrieving
OrderResource
by the reference and not the ID because I don't want people to know how many orders there are. An order is not a relationship? Maybe my question is poorly phrased?If it for a particular panel then it sounds like you need a separate resource for that panel that modifies the base query for the table.
Or a callback that modifies the base query for the the records based on the panel. You can get the panel in any callback with filament()->getCurrentPanel()
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:
and then override the function that resolves the record: