maulik/filament-auto-crud

Automatically generate Filament resources from Laravel models and database tables

1.0.0 2025-03-19 07:04 UTC

This package is auto-updated.

Last update: 2025-04-19 16:08:42 UTC


README

This Laravel package automatically generates Filament resources (CRUD panels) based on your existing models or database tables. It analyzes your database schema and model relationships to create fully functional Filament resources with minimal configuration.

Features

  • Automatically generate Filament resources from existing models
  • Detect and configure appropriate form fields based on column types
  • Handle model relationships (belongsTo, hasMany, etc.)
  • Customizable field type mappings
  • Support for common column types
  • Exclude specific tables/models from generation
  • Optional AI-powered field configuration (requires OpenAI API key)

Requirements

  • PHP 8.1 or higher
  • Laravel 10.x or 11.x
  • Filament 3.x

Installation

composer require maulik/filament-auto-crud

Configuration

Publish the configuration file:

php artisan vendor:publish --provider="Maulik\FilamentAutoCrud\FilamentAutoCrudServiceProvider"

This will create a config/filament-auto-crud.php file where you can customize:

  • Excluded tables/models Then, enable AI settings in the configuration file:
'ai' => [
    'enabled' => true,
    'model' => 'gpt-3.5-turbo',
],

Contributing

Contributions are welcome! Please submit a Pull Request.

License

This package is open-sourced software licensed under the MIT license.- Field type mappings

  • Relationship field types
  • Resource generation path
  • AI integration settings (optional)

Usage

Generate a Resource for a Single Model

php artisan filament:generate-resource User

Or with full namespace:

php artisan filament:generate-resource "App\Models\User"

Generate Resources for All Models

php artisan filament:generate-resources

Options:

  • --path: The path to look for models (default: app/Models)
  • --namespace: The namespace of the models (default: App\Models)

Customization

Field Type Mappings

You can customize how database column types map to Filament field types in the configuration file:

'field_types' => [
    'string' => 'TextInput',
    'text' => 'Textarea',
    'integer' => 'TextInput::numeric',
    'boolean' => 'Toggle',
    // ...
],

Relationship Field Types

Configure how different relationship types are rendered:

'relationship_types' => [
    'belongsTo' => 'Select',
    'hasMany' => 'Repeater',
    'belongsToMany' => 'MultiSelect',
    // ...
],

Excluding Tables/Models

Specify which tables or models should be excluded from resource generation:

'exclude' => [
    'migrations',
    'password_resets',
    'failed_jobs',
    // ...
],

AI Integration (Optional)

Enable AI-powered features by setting your OpenAI API key in your .env file:

OPENAI_API_KEY=your-api-key

Then enable AI integration in the configuration:

'ai' => [
    'enabled' => true,
    'model' => 'gpt-3.5-turbo',
],

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This package is open-sourced software licensed under the MIT license.