Filament getTabs method for table on custom resource page
I have a resource DriverResource. I want to add a custom page with driver statistics to this resource and have tabs above the table. I added the tabs, they are displayed, but the content does not change when clicked. There are no errors in the console or logs
My route path /admin/drivers/{driver_id}/statistics

12 Replies
Never use route params when working with Livewire. They aren't there on Livewire requests.
getTabs()
is a feature of the ListPage
and the logic is implemented there. If you just add a getTabs()
I'd expect nothing to change. How did you get the tabs over the table?I did it like in the example here https://github.com/filamentphp/filament/discussions/10127#discussioncomment-8206452
At the moment I made the type ListRecords instead Page. But there is a problem. I get the record only on the first page load. I understand that the problem is that I can't get record id.
Inside DriverResource I declared a route. Then I want to use this id to get statistics
GitHub
Tabs in custom page · filamentphp filament · Discussion #10127
hello there! please need a help on how to make a tabs on custompage in filament? i have create a custom page named product linked with a resource named categoryResource.Then when i tried to use the...
@Dennis Koch
I did it and now it works, but I don't really like the way. Maybe I chose the wrong way.
Nope, looks good to me.
Just the property
public $record
doesn't work? 🤔@Dennis Koch The page works fine, the tabs work. But the widgets don't work, despite the fact that I made the mount. Is there another way to mount ? For example, if I write statically 14, then the widgets work $this->driverId = 14;
Hm that's weird. Did you try debugging whether
request()->route('record')
is null at any point?I have the following error. At the same time, the page and pagination work fine, tabs switch without errors
[2025-03-17 14:45:54] local.ERROR: Cannot assign null to property App\Filament\Resources\DriverResource\Pages\StatDrivers::$driverId of type int (View: /var/www/app/vendor/filament/widgets/resources/views/stats-overview-widget.blade.php) {"userId":1,"exception":"[object] (Illuminate\View\ViewException(code: 0): Cannot assign null to property App\Filament\Resources\DriverResource\Pages\StatDrivers::$driverId of type int (View: /var/www/app/vendor/filament/widgets/resources/views/stats-overview-widget.blade.php) at /var/www/app/app/Filament/Resources/DriverResource/Pages/StatDrivers.php:38)
What does the widget look like?
GitHub
I created a ListRecords with a parameter in route and my widgets do...
Package Panel builder Package Version 3.3.0 How can we help you? This is my route in the driverresource file 'stat' => Pages\StatDrivers::route('/{record}/statistics'), If I use ...
What happened if you use the
$record
instead of $driverId
? I think the widgets can implement a InteractsWithRecord
trait?There is a conflict with this trait
use ExposesTableToWidgets;
@Dennis Koch This is because the trigger fires and the mount is called again, but it cannot find the route or record. See line #12