定制 mgamal92/filament-demo-generator 二次开发

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

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

mgamal92/filament-demo-generator

最新稳定版本:v1.4.0

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 DemoDataGenerated event after creation for extensibility
  • Smart field detection using fillable
  • Auto-handles BelongsTo relationships
  • 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 fillable attributes.

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.

  1. Fork the repo
  2. Make your changes
  3. Submit a PR

License

MIT License

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固