Installation:
composer require tomatophp/filament-helpers
Publish the package config (if needed) with:
php artisan vendor:publish --provider="TomatoPHP\FilamentHelpers\FilamentHelpersServiceProvider"
First Command Execution: Run the generator command:
php artisan filament:helpers
UserForm or UserTable).First Use Case:
form() method in your Filament resource with:
use App\Filament\Resources\AccountResource\Forms\UserForm;
public function form(Form $form): Form
{
return UserForm::make($form);
}
table() method with:
use App\Filament\Resources\AccountResource\Tables\UserTable;
public function table(Table $table): Table
{
return UserTable::make($table);
}
Modular Organization:
/Modules/Account/Resources/AccountResource/
├── Forms/
│ └── UserForm.php
└── Tables/
└── UserTable.php
Reusable Components:
namespace App\Filament\Resources\Shared;
use TomatoPHP\FilamentHelpers\Helpers\FormHelper;
class BaseUserForm extends FormHelper
{
protected function configure(): void
{
$this->schema([
TextInput::make('name')->required(),
]);
}
}
use App\Filament\Resources\Shared\BaseUserForm;
class UserForm extends BaseUserForm { ... }
Dynamic Configuration:
protected function getFormSchema(): array
{
return [
TextInput::make('email')
->required()
->email(),
Select::make('role')
->options(fn () => Role::all()->pluck('name', 'id')),
];
}
Action Integration:
use TomatoPHP\FilamentHelpers\Helpers\ActionHelper;
class ExportUsersAction extends ActionHelper
{
protected function handle(): void
{
// Custom export logic
}
}
Testing:
$formHelper = Mockery::mock(UserForm::class);
$formHelper->shouldReceive('make')
->andReturn($form);
Rapid Prototyping:
php artisan filament:helpers --type=Form --name=UserForm --resource=AccountResource
Edit app/Filament/Resources/AccountResource/Forms/UserForm.php.Team Collaboration:
configure() in a base helper class.Migration from Default Forms/Tables:
- public function form(Form $form): Form { return $form; }
+ public function form(Form $form): Form { return UserForm::make($form); }
Namespace Conflicts:
--path flag to specify a custom directory:
php artisan filament:helpers --path=app/Filament/Helpers
Caching Issues:
php artisan filament:cache-clear
config/filament.php temporarily during development.Overwriting Files:
--force flag in future updates).Dynamic Dependencies:
// ❌ Avoid
class UserForm extends BaseForm { ... }
class BaseForm extends UserForm { ... }
Filament Version Compatibility:
filament/filament:^3.0). The package may not support all minor versions.Generated Class Not Loading:
composer dump-autoload
use statement (e.g., UserForm vs. userForm).Blank/Unrendered Forms/Tables:
configure() or make() method is not empty.CSRF or Validation Errors:
_method, _token) are missing.protected function configure(): void
{
$this->schema([...])->columns([...]);
$this->extraAttributes(['_method' => 'PUT']);
}
Customize the Generator:
php artisan vendor:publish --tag=filament-helpers-templates
resources/views/vendor/filament-helpers/.Partial Generation:
php artisan filament:helpers --type=Form --name=UserForm --schema-only
IDE Support:
Performance:
protected function getTableColumns(): array
{
return fn () => [
TextColumn::make('name'),
// Dynamically load other columns
];
}
Extending Functionality:
trait HasSoftDeletes
{
public static function make(Form $form): Form
{
return parent::make($form)
->schema([
Toggle::make('is_active')
->default(true),
]);
}
}
use HasSoftDeletes;
class UserForm extends FormHelper
{
use HasSoftDeletes;
}
Documentation:
/**
* @return array<int, Column>
*/
protected function getTableColumns(): array { ... }
How can I help you explore Laravel packages today?