mgamal92/filament-demo-generator
Composer 安装命令:
composer require mgamal92/filament-demo-generator
包简介
Generate demo data for any Filament resource
README 文档
README
A Filament plugin that helps you generate realistic demo data for any resource — in just one click.
Whether you're testing layouts, showcasing features, or kicking off a new dashboard — skip writing manual seeders and fill your tables instantly.
Features
- One smart "Generate / Delete Demo Data" button added to any resource
- Dynamic label, color, and modal content based on state
- Custom modal with option to set number of records
- Built-in delete confirmation for demo data
- Caches generated record IDs for precise cleanup
- Fires
DemoDataGeneratedevent after creation for extensibility - Smart field detection using
fillable - Auto-handles
BelongsTorelationships - Enum fields are fully supported — random value selected automatically
- Faker-powered values based on field types
- Supports text, number, email, dates, enums, and more
- Fully extendable — hook into the generator or replace logic as needed
BelongsTo Relationships
The package automatically handles BelongsTo relationships:
- If related records exist, a random one is selected and linked.
- If no related records are found, a new record is created and linked automatically.
- This process does not require Laravel factories and works based on
fillableattributes.
For example, if your model has a user_id field and a user() relationship, the generator will automatically populate it correctly.
Event: DemoDataGenerated
After demo data is created, the following event is fired:
Mgamal92\FilamentDemoGenerator\Events\DemoDataGenerated
You can listen to it like this:
use Mgamal92\FilamentDemoGenerator\Events\DemoDataGenerated; Event::listen(DemoDataGenerated::class, function ($event) { logger('Demo generated for: ' . $event->model); });
Payload includes:
$event->model$event->count$event->ids(array of record IDs)
Configuration
You can customize how fake demo data is generated by publishing the config file:
php artisan vendor:publish --tag=config --provider="Mgamal92\FilamentDemoGenerator\FilamentDemoGeneratorServiceProvider"
This will create a filament-demo-generator.php file in your config directory. You can customize:
- Value generators for specific field names (e.g., "email", "phone")
- Generators by column type (e.g., "string", "integer", "date")
- Supported faker patterns
Installation
composer require mgamal92/filament-demo-generator
Usage
After installation, a "Generate Demo Data" button will appear in the table header of any Filament resource.
If demo data already exists, the same button becomes "Delete Demo Data", and deletes only the records it generated.
Contributing
Contributions are welcome!
If you have suggestions for improving the plugin, want to support new field types, or help with localization, feel free to open an issue or submit a pull request.
- Fork the repo
- Make your changes
- Submit a PR
License
MIT License
mgamal92/filament-demo-generator 适用场景与选型建议
mgamal92/filament-demo-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 07 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mgamal92/filament-demo-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mgamal92/filament-demo-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-13