定制 filahq/statify-easy-widget 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

filahq/statify-easy-widget

Composer 安装命令:

composer require filahq/statify-easy-widget

包简介

Build Filament stat widgets from Eloquent models with a fluent API.

README 文档

README

Build Filament stat widgets from Eloquent models with a fluent API.

Installation

composer require filahq/statify-easy-widget

The core package only requires Filament widgets. If you want to register the optional StatifyEasyWidgetPlugin with a Filament panel, install full Filament too:

composer require filament/filament

Statify Easy Widget supports both Filament 4 and Filament 5.

Usage

Extend EasyStatsWidget and define your stats in a stats() method using the fluent Stat builder:

use FilaHQ\StatifyEasyWidget\Builder\Stat;
use FilaHQ\StatifyEasyWidget\Widgets\EasyStatsWidget;

class RevenueStatsWidget extends EasyStatsWidget
{
    protected function stats(): array
    {
        return [
            Stat::make('Revenue Today')
                ->model(Order::class)
                ->attribute('total')
                ->where('created_at', '>=', today())
                ->sum()
                ->prefix('$')
                ->color('success')
                ->description('+12% from yesterday')
                ->chartLastDays(7),

            Stat::make('Users Today')
                ->model(User::class)
                ->where('created_at', '>=', today())
                ->count()
                ->color('info')
                ->chartLastDays(30),

            Stat::make('Avg Order Value')
                ->model(Order::class)
                ->attribute('total')
                ->where('created_at', '>=', now()->startOfMonth())
                ->avg()
                ->prefix('$')
                ->suffix(' avg'),
        ];
    }
}

Register the widget in your Filament panel as you normally would:

$panel->widgets([
    RevenueStatsWidget::class,
]);

Builder API

Query

Method Description
model(string $class) Eloquent model class to query
attribute(string $column) Column to aggregate (required for sum, avg, min, max)
where(string $column, mixed $value) Adds a = condition
where(string $column, string $operator, mixed $value) Adds a condition with explicit operator
count() Aggregate: row count
sum() Aggregate: column sum
avg() Aggregate: column average
min() Aggregate: column minimum
max() Aggregate: column maximum

Multiple where() calls accumulate — all conditions are applied to the query.

Decoration

Method Description
prefix(string $prefix) Prepended to the computed value (e.g. '$')
suffix(string $suffix) Appended to the computed value (e.g. ' users')
color(string $color) Filament color ('success', 'danger', 'warning', 'info', etc.)
icon(string|BackedEnum $icon) Heroicon name or Heroicon enum case
description(string $description) Secondary label shown below the value
chart(array $data) Static array of numeric values for the sparkline
chartLastDays(int $days, string $dateColumn = 'created_at') Generates a sparkline from the last N days of model data

Chart

chartLastDays() automatically builds a sparkline by running the same aggregate for each of the last N days. The same where() conditions are applied per day, scoped to that day's date range.

// Sparkline from the last 7 days, using created_at (default)
->chartLastDays(7)

// Sparkline from the last 30 days, using a custom date column
->chartLastDays(30, 'completed_at')

If both chart() and chartLastDays() are set, the static chart() array takes precedence.

Filament Plugin (optional)

If you want to register the plugin with your Filament panel, install filament/filament and then register:

use FilaHQ\StatifyEasyWidget\StatifyEasyWidgetPlugin;

$panel->plugin(StatifyEasyWidgetPlugin::make());

Statify Compatibility

Widgets built with EasyStatsWidget are compatible with the filahq/statify package out of the box. Register them normally and they can be exposed through the Statify API.

composer require filahq/statify

License

MIT

filahq/statify-easy-widget 适用场景与选型建议

filahq/statify-easy-widget 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「stats」 「laravel」 「widget」 「eloquent」 「filament」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 filahq/statify-easy-widget 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 filahq/statify-easy-widget 我们能提供哪些服务?
定制开发 / 二次开发

基于 filahq/statify-easy-widget 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 37
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-18