F
Filament15mo ago
prowler

Adding title to a stats overview widget

Hello, i created some simple stats overview widget with the php artisan command. How can i add a title above it? Haven't found anything in the documentation about that. Thanks in advance.
5 Replies
prowler
prowlerOP15mo ago
im talking about a simple widget like this -
<?php

namespace App\Filament\Widgets;

use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;
use Illuminate\Contracts\Support\Htmlable;

class TopEpcBrands extends BaseWidget
{
protected static ?int $sort = 1;

protected function getStats(): array
{
return [ ... ];
}
}
<?php

namespace App\Filament\Widgets;

use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;
use Illuminate\Contracts\Support\Htmlable;

class TopEpcBrands extends BaseWidget
{
protected static ?int $sort = 1;

protected function getStats(): array
{
return [ ... ];
}
}
should i actually override its render method? anyone, please?
Patrick Boivin
Patrick Boivin15mo ago
You could customize the view:
protected static string $view = 'my-stats-overview-widget';
protected static string $view = 'my-stats-overview-widget';
ssmusoke
ssmusoke15mo ago
Which blade file then does one override to make the relevant changes
prowler
prowlerOP15mo ago
what?
DrByte
DrByte15mo ago
Yes, you could override the render() method and have it call a different template, one that you copy from the base and make adjustments to. Just be sure to update it anytime the base templates get updated. Notice how use Filament\Widgets\StatsOverviewWidget\Stat; is part of the generated stats widget ? If you scroll to the bottom of that class you'll see the render() method which names which blade template it uses.
Want results from more Discord servers?
Add your server