PHP code example of a909m / filament-generate-helpers

1. Go to this page and download the library: Download a909m/filament-generate-helpers library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

a909m / filament-generate-helpers example snippets


php artisan filament-generate-helpers:run User

namespace App\Filament\Resources\UserResource;

use App\Filament\Helpers\User\UserHelper;
use Filament\Resources\Resource;

class UserResource extends Resource
{
    public static function form(Form $form): Form
    {
        return $form->schema(
            UserHelper::formFields()
        );
    }

    public static function table(Table $table): Table
    {
        return $table->columns(
            UserHelper::tableColumns()
        );
    }
}



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::passwordField(),
        ];
    }

    public static function tableColumns(): array
    {
        return [
            static::nameColumn(),
            static::emailColumn(),
            static::createdAtColumn(),
        ];
    }
}

return $form->schema([
    TextInput::make('name')->ord::make('password')->

return $form->schema(UserHelper::formFields());

.
+-- Helpers
|   +-- User
|   |   +-- UserHelper.php
|   |   +-- Traits
|   |   |   +-- UserFormFields.php
|   |   |   +-- UserTableColumns.php