F
Filament15mo ago
Hasith

can i add action button to a stat widget?

I have this widget card. i want to add a button to it and when the user click it I want to delete a record inside the database. Is it possible to add action and how can I do that?
class WarningWidget extends BaseWidget
{
protected static ?int $sort = -2;

protected function getColumns(): int
{
return 1;
}

public static function canView():bool
{

return true;

}

protected function getStats(): array
{
return [

Stat::make('Unknown API Request','')
->description('We are having unknown API request from a unregistered domain')
->icon('heroicon-m-exclamation-triangle')
->color('danger'),

];
}
}
class WarningWidget extends BaseWidget
{
protected static ?int $sort = -2;

protected function getColumns(): int
{
return 1;
}

public static function canView():bool
{

return true;

}

protected function getStats(): array
{
return [

Stat::make('Unknown API Request','')
->description('We are having unknown API request from a unregistered domain')
->icon('heroicon-m-exclamation-triangle')
->color('danger'),

];
}
}
7 Replies
Hugo
Hugo15mo ago
I think you'll have to use a custom component
Hasith
HasithOP15mo ago
How i use custom component as a widget? 🤔
Hasith
HasithOP15mo ago
Yeah, I can call a function using wire:click. Currently, I'm using this method. Right now it's affecting the whole card. But if I can add a small button inside the Stat card and add action to that button it would be awesome. Such as the Sign Out button on the default Auth widget. @leandro_ferreira
Hasith
HasithOP15mo ago
Okay. I will try this and get back here if need help. Thank you ❤️
jvkassi
jvkassi3mo ago
Hello, kinda an old issue, but i think i'tll be cool to add actions button to the stat widget
Want results from more Discord servers?
Add your server