PHP code example of laboiteacode / filament-dashboard-widgets
1. Go to this page and download the library: Download laboiteacode/filament-dashboard-widgets library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
laboiteacode / filament-dashboard-widgets example snippets
use LaBoiteACode\FilamentDashboardWidgets\FilamentDashboardWidgetsPlugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
FilamentDashboardWidgetsPlugin::make(),
]);
}
protected function getHeaderWidgets(): array
{
return [
MonthlyRevenueWidget::class,
ConversionGoalWidget::class,
CustomerBreakdownWidget::class,
];
}
use Illuminate\Support\Number;
use LaBoiteACode\FilamentDashboardWidgets\Data\Metric;
use LaBoiteACode\FilamentDashboardWidgets\Widgets\MetricWidget;
class MonthlyRevenueWidget extends MetricWidget
{
protected function getMetric(): Metric
{
return Metric::make('Monthly revenue', 24_850)
->formatUsing(fn (int $value) => Number::currency($value, 'EUR'))
->description('Compared to last month')
->trend(12.4)
->icon('heroicon-o-banknotes')
->color('success')
->sparkline([12, 14, 13, 18, 20, 19, 24])
->url(route('filament.admin.resources.orders.index'));
}
}
use Illuminate\Support\Number;
use LaBoiteACode\FilamentDashboardWidgets\Data\Goal;
use LaBoiteACode\FilamentDashboardWidgets\Widgets\GoalProgressWidget;
class ConversionGoalWidget extends GoalProgressWidget
{
protected function getGoal(): Goal
{
return Goal::make('Monthly goal', current: 72_500, target: 100_000)
->formatUsing(fn ($value) => Number::currency($value, 'EUR'))
->deadline(now()->endOfMonth())
->color('primary')
->showRemaining()
->showPercentage();
}
}
use Illuminate\Support\Number;
use LaBoiteACode\FilamentDashboardWidgets\Data\RecentItem;
use LaBoiteACode\FilamentDashboardWidgets\Widgets\RecentItemsWidget;
class RecentOrdersWidget extends RecentItemsWidget
{
protected ?string $heading = 'Recent orders';
protected function getViewAllUrl(): ?string
{
return OrderResource::getUrl('index');
}
protected function getItems(): array
{
return Order::query()
->latest()
->limit(5)
->get()
->map(fn (Order $order) => RecentItem::make(
title: "#{$order->number}",
description: $order->customer->name,
)
->meta(Number::currency($order->total, 'EUR'))
->badge($order->status->getLabel())
->badgeColor($order->status->getColor())
->url(OrderResource::getUrl('view', ['record' => $order])))
->all();
}
}
use LaBoiteACode\FilamentDashboardWidgets\Data\BreakdownItem;
use LaBoiteACode\FilamentDashboardWidgets\Widgets\BreakdownWidget;
class CustomerBreakdownWidget extends BreakdownWidget
{
protected ?string $heading = 'Customers by status';
protected function getItems(): array
{
return [
BreakdownItem::make('Active', 148)
->color('success')
->icon('heroicon-o-check-circle'),
BreakdownItem::make('Pending', 32)
->color('warning'),
BreakdownItem::make('Inactive', 12)
->color('gray'),
];
}
}
use LaBoiteACode\FilamentDashboardWidgets\Data\Trend;
use LaBoiteACode\FilamentDashboardWidgets\Data\TrendPoint;
use LaBoiteACode\FilamentDashboardWidgets\Widgets\TrendWidget;
class NewCustomersTrendWidget extends TrendWidget
{
protected function getTrend(): Trend
{
return Trend::make('New customers')
->value(184)
->comparison(16.8)
->points([
TrendPoint::make('2026-07-01', 18),
TrendPoint::make('2026-07-02', 24),
TrendPoint::make('2026-07-03', 21),
])
->type('area')
->color('primary');
}
}
use Illuminate\Support\Number;
use LaBoiteACode\FilamentDashboardWidgets\Data\Composition;
use LaBoiteACode\FilamentDashboardWidgets\Data\CompositionSlice;
use LaBoiteACode\FilamentDashboardWidgets\Widgets\CompositionWidget;
class RevenueCompositionWidget extends CompositionWidget
{
protected function getComposition(): Composition
{
return Composition::make('Revenue by channel')
->type('doughnut')
->formatUsing(fn (float $value) => Number::currency($value, 'EUR'))
->slices([
CompositionSlice::make('Direct', 12_000)->color('primary'),
CompositionSlice::make('Marketplace', 8_000)->color('success'),
CompositionSlice::make('Partners', 5_000)->color('warning'),
]);
}
}
use Illuminate\Support\Number;
use LaBoiteACode\FilamentDashboardWidgets\Data\Detail;
use LaBoiteACode\FilamentDashboardWidgets\Widgets\DetailListWidget;
class CustomerDetailWidget extends DetailListWidget
{
protected ?string $heading = 'Customer';
protected function getDetails(): array
{
return [
Detail::make('Status', 'Active')->badge('Active')->badgeColor('success'),
Detail::make('Plan', 'Pro')->icon('heroicon-o-star'),
Detail::make('MRR', 4_900)->formatUsing(fn (int $value) => Number::currency($value, 'EUR')),
Detail::make('Website', 'example.test')->url('https://example.test'),
Detail::make('Notes', null),
];
}
}
use LaBoiteACode\FilamentDashboardWidgets\Data\Bullet;
use LaBoiteACode\FilamentDashboardWidgets\Widgets\BulletWidget;
class SatisfactionBulletWidget extends BulletWidget
{
protected function getBullet(): Bullet
{
return Bullet::make('Customer satisfaction', 82)
->target(90)
->max(100)
->comparative(75)
->ranges([50, 75])
->formatUsing(fn (float $value) => "{$value}%");
}
}
use LaBoiteACode\FilamentDashboardWidgets\Data\FunnelStage;
use LaBoiteACode\FilamentDashboardWidgets\Widgets\FunnelWidget;
class SignupFunnelWidget extends FunnelWidget
{
protected ?string $heading = 'Signup funnel';
protected function getStages(): array
{
return [
FunnelStage::make('Visitors', 4_200),
FunnelStage::make('Signups', 1_280),
FunnelStage::make('Activated', 640),
FunnelStage::make('Paying', 210)->color('success'),
];
}
}
use LaBoiteACode\FilamentDashboardWidgets\Data\TimelineEvent;
use LaBoiteACode\FilamentDashboardWidgets\Widgets\TimelineWidget;
class ActivityTimelineWidget extends TimelineWidget
{
protected ?string $heading = 'Recent activity';
protected function shouldGroupByDay(): bool
{
return true;
}
protected function getViewAllUrl(): ?string
{
return ActivityResource::getUrl('index');
}
protected function getEvents(): array
{
return Activity::query()
->latest()
->limit(8)
->get()
->map(fn (Activity $activity) => TimelineEvent::make($activity->description)
->timestamp($activity->created_at)
->icon('heroicon-o-bolt')
->color('primary')
->actor($activity->causer?->name))
->all();
}
}
use LaBoiteACode\FilamentDashboardWidgets\Data\VarianceItem;
use LaBoiteACode\FilamentDashboardWidgets\Widgets\VarianceWidget;
class TopMoversWidget extends VarianceWidget
{
protected ?string $heading = 'Top movers this week';
protected function shouldSortByChange(): bool
{
return true;
}
protected function getItems(): array
{
return [
VarianceItem::make('Enterprise', 3_200)->previous(2_600),
VarianceItem::make('SMB', 1_800)->previous(2_100),
VarianceItem::make('Startup', 900)->previous(600),
];
}
}
use LaBoiteACode\FilamentDashboardWidgets\Data\BreakdownItem;
use LaBoiteACode\FilamentDashboardWidgets\Widgets\SegmentBarWidget;
class TrafficSegmentWidget extends SegmentBarWidget
{
protected ?string $heading = 'Traffic by source';
protected function getSegments(): array
{
return [
BreakdownItem::make('Organic', 5_400)->color('success'),
BreakdownItem::make('Direct', 2_600)->color('primary'),
BreakdownItem::make('Referral', 1_200)->color('warning'),
];
}
}
use LaBoiteACode\FilamentDashboardWidgets\Data\UsageLimit;
use LaBoiteACode\FilamentDashboardWidgets\Widgets\UsageLimitsWidget;
class ResourceUsageWidget extends UsageLimitsWidget
{
protected ?string $heading = 'Plan usage';
protected function getLimits(): array
{
return [
UsageLimit::make('Seats', 42, 50)->warnThreshold(0.8)->icon('heroicon-o-users'),
UsageLimit::make('Storage', 380, 500)
->warnThreshold(0.9)
->formatUsing(fn (float $value): string => number_format($value).' GB'),
UsageLimit::make('API calls', 92_000, 100_000)->warnThreshold(0.8),
];
}
}
use LaBoiteACode\FilamentDashboardWidgets\Data\ChartSeries;
use LaBoiteACode\FilamentDashboardWidgets\Widgets\ComparisonChartWidget;
class RevenueVsTargetWidget extends ComparisonChartWidget
{
protected ?string $heading = 'Revenue vs target';
protected function getLabels(): array
{
return ['Jan', 'Feb', 'Mar', 'Apr'];
}
protected function getSeries(): array
{
return [
ChartSeries::make('Actual')->values([12, 18, 15, 22])->color('primary')->filled(),
ChartSeries::make('Target')->values([14, 16, 18, 20])->color('gray'),
];
}
}
use LaBoiteACode\FilamentDashboardWidgets\Data\Card;
use LaBoiteACode\FilamentDashboardWidgets\Data\WidgetAction;
use LaBoiteACode\FilamentDashboardWidgets\Widgets\CardWidget;
class ActiveUsersCardWidget extends CardWidget
{
protected function getCard(): Card
{
return Card::make('Active users')
->variant('stat')
->value(2_318)
->formatUsing(fn (int $value): string => number_format($value))
->description('Compared to last week')
->badge('+8.1%')
->badgeColor('success')
->icon('heroicon-o-users')
->color('primary');
}
}
Card::make('Invite your team')
->variant('cta')
->icon('heroicon-o-user-plus')
->description('Collaborate by adding your colleagues to the workspace.')
->actions([
WidgetAction::make('Send invites')->url('/team/invite')->icon('heroicon-m-paper-airplane'),
WidgetAction::make('Learn more')->url('/docs/team'),
]);
// On the data objects
->color('primary')
->icon('heroicon-o-chart-bar')
->url('/admin/orders')
->openUrlInNewTab()
// On the widgets (override the methods or set the properties)
protected ?string $heading = 'Recent orders';
protected function getEmptyStateHeading(): ?string
{
return 'No orders yet';
}
protected int | string | array $columnSpan = 2;
// config/filament-dashboard-widgets.php
'polling_interval' => '30s',
class LiveVisitorsWidget extends MetricWidget
{
protected ?string $pollingInterval = '10s';
}
protected function getMetric(): Metric
{
return Cache::remember('dashboard.monthly-revenue', now()->addMinutes(5), fn () =>
Metric::make('Monthly revenue', $this->computeRevenue()));
}
bash
php artisan vendor:publish --tag="filament-dashboard-widgets-config"
php artisan vendor:publish --tag="filament-dashboard-widgets-translations"
bash
php artisan vendor:publish --tag="filament-dashboard-widgets-translations"