How can I retrieve the record ID inside the getTableQuery
method in a custom resource in filamentPHP, so that I can dynamically display table data based on this record? Specifically, I have the following custom action:
Tables\Actions\EditAction::make()
->url(fn (Container $record): string => ContainerResource::getUrl('listOrders', ['record' => $record]))
And I want to use the retrieved record ID in the where
clause of the getTableQuery
as shown below:
$query = Order::join('containers', 'orders.container_id', '=', 'containers.container_id')
->where('orders.container_id', /* I need to insert the record ID here, but how can I get it? */);
Note: The custom resource is for a system that manages orders and containers, and I want to list orders for a specific container based on the record ID retrieved from the URL when editing a container.