Pass parameter from URL to table header action
Hi, is there a way to pass a URL parameter to an action in the table header?
For example I'm on the resource index page mywebsite.com/resourcename?param=1 and I'm trying to get the value "1" in the table header action. I tried "request('param')" but it's null, also $data and $record are empty.
Thank you.
1 Reply
I'm filtering the table results based on that param. I have this in my resource:
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()->when(request()->has('param'), function ($query) {
$query->where('id', request('param'));
});
}