Skip to content

Effortlessly generate reusable form fields and table column helpers for Filament resources based on Laravel models, streamlining your development workflow.

License

Notifications You must be signed in to change notification settings

YemenOpenSource/Filament-Generate-Helpers

 
 

Repository files navigation

Filament-Generate-Helpers

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Effortlessly generate reusable form fields and table column helpers for Filament resources based on Laravel models, streamlining your development workflow.

Features

  • Automatically generates reusable form fields and table columns.
  • Organizes fields and columns into traits and a helper class.
  • Simplifies resource management for Filament developers.

Installation

You can install the package via composer:

composer require a909m/filament-generate-helpers

Usage

To Generate a Helpers for the App\Models\Usermodel, 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

Under the Hood

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(),

        ];
    }
}

Benefits

  • 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.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

Effortlessly generate reusable form fields and table column helpers for Filament resources based on Laravel models, streamlining your development workflow.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%