Effortlessly generate reusable form fields and table column helpers for Filament resources based on Laravel models, streamlining your development workflow.
- Automatically generates reusable form fields and table columns.
- Organizes fields and columns into traits and a helper class.
- Simplifies resource management for Filament developers.
You can install the package via composer:
composer require a909m/filament-generate-helpers
To Generate a Helpers for the App\Models\User
model, run:
php artisan filament-generate-helpers:run User
This will create the following files under the app/Filament/Helpers/User
directory:
.
+-- Helpers
| +-- User
| | +-- UserHelper.php
| | +-- Traits
| | | +-- UserFormFields.php
| | | +-- UserTableColumns.php
The generated helpers are similar to Filament's Automatically generating forms and tables
but are grouped into traits for better reusability. For example, for the User
model:
<?php
namespace App\Filament\Helpers\User;
use App\Filament\Helpers\User\Traits\UserFormFields;
use App\Filament\Helpers\User\Traits\UserTableColumns;
class UserHelper
{
use UserFormFields ,UserTableColumns;
public static function formFields(): array
{
return [
static::nameField(),
static::emailField(),
static::emailVerifiedAtField(),
static::passwordField(),
];
}
public static function tableColumns(): array
{
return [
static::nameColumn(),
static::emailColumn(),
static::emailVerifiedAtColumn(),
static::createdAtColumn(),
static::updatedAtColumn(),
];
}
}
- Separation of Concerns: Fields and columns are neatly organized into traits.
- Reusability: The helper and traits can be reused across multiple resources.
- Customization: Easily modify the generated traits and helper classes.
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.