F
Filament9mo ago
jabs

Hi,

I made a Statsoverview widget and have 5 stats added into that widget. I am trying to put the columns at 5 so it will display 5 stats on the same row, however, each stat will turn into a fullspan widget. What can i do to achieve this? This is my widget code.
class EarnedStats extends BaseWidget
{
public ?Event $record = null;

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

protected static ?string $pollingInterval = '10s';

protected function getStats(): array
{
$event = $this->record;

$earnedKickBackFeeValue = number_format($event->earnedKickbackFeeValue(), 2, '.', ',');
$soldOnline = number_format($event->onlineTickets()->sum('price'), 2, '.', ',');
$soldCashRegister = number_format($event->cashPaymentsTickets()->sum('price'), 2, '.', ',');
$totalDiscount = number_format($event->totalDiscount(), 2, '.', ',');
$totalEarned = number_format($event->onlineTicketsSellValue(), 2, '.', ',');

return [
Stat::make(__('Total kickback fee'), "€ {$earnedKickBackFeeValue}"),
Stat::make(__('Sold online'), "€ {$soldOnline}"),
Stat::make(__('Sold with cash register'), "€ {$soldCashRegister}"),
Stat::make(__('Total discounts'), "- € {$totalDiscount}"),
Stat::make(__('Total'), "€ {$totalEarned}"),
];
}
}
class EarnedStats extends BaseWidget
{
public ?Event $record = null;

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

protected static ?string $pollingInterval = '10s';

protected function getStats(): array
{
$event = $this->record;

$earnedKickBackFeeValue = number_format($event->earnedKickbackFeeValue(), 2, '.', ',');
$soldOnline = number_format($event->onlineTickets()->sum('price'), 2, '.', ',');
$soldCashRegister = number_format($event->cashPaymentsTickets()->sum('price'), 2, '.', ',');
$totalDiscount = number_format($event->totalDiscount(), 2, '.', ',');
$totalEarned = number_format($event->onlineTicketsSellValue(), 2, '.', ',');

return [
Stat::make(__('Total kickback fee'), "€ {$earnedKickBackFeeValue}"),
Stat::make(__('Sold online'), "€ {$soldOnline}"),
Stat::make(__('Sold with cash register'), "€ {$soldCashRegister}"),
Stat::make(__('Total discounts'), "- € {$totalDiscount}"),
Stat::make(__('Total'), "€ {$totalEarned}"),
];
}
}
This is the results.
No description
5 Replies
jabs
jabsOP9mo ago
Anyone has a idea?
toeknee
toeknee9mo ago
Stat::make(__('Total kickback fee'), "€ {$earnedKickBackFeeValue}")->colspan(1) Does that work?
Dennis Koch
Dennis Koch9mo ago
I think the stat widget grid is limited to 4 cols
LeandroFerreira
LeandroFerreira9mo ago
I think the same
jabs
jabsOP9mo ago
Kinda weird that it does work if the widget is displayed on a dashboard page, since there i can change the columns to 5, Thank you anyways!
Want results from more Discord servers?
Add your server