PHP code example of greatwolf3 / filament-module-generator
1. Go to this page and download the library: Download greatwolf3/filament-module-generator 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/ */
greatwolf3 / filament-module-generator example snippets
protected $fillable = [
'name',
'name_it',
'name_en',
'name_fr',
];
Schema::create('products', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('name_it')->nullable();
$table->string('name_en')->nullable();
$table->string('name_fr')->nullable();
$table->timestamps();
});
public static function form(Schema $form): Schema
{
return $form
->schema([
Forms\Components\TextInput::make('name_it')
->label('Name (it)')
->maxLength(255),
Forms\Components\TextInput::make('name_en')
->label('Name (en)')
->maxLength(255),
Forms\Components\TextInput::make('name_fr')
->label('Name (fr)')
->maxLength(255),
Forms\Components\TextInput::make('name')
->
class ProductResource extends Resource
{
protected static ?string $model = Product::class;
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $slug = 'ecommerce/products';
protected static string|UnitEnum|null $navigationGroup = 'Ecommerce';
public static function form(Schema $form): Schema
{
return $form
->schema([
// Automatically generated multilingual fields
Forms\Components\TextInput::make('name_it')
->label('Name (it)')
->maxLength(255),
Forms\Components\TextInput::make('name_en')
->label('Name (en)')
->maxLength(255),
Forms\Components\TextInput::make('name')
->dex' => Pages\ListProducts::route('/'),
'create' => Pages\CreateProduct::route('/create'),
'edit' => Pages\EditProduct::route('/{record}/edit'),
];
}
}
->discoverResources(in: base_path('Modules/Ecommerce/Filament/Resources'), for: 'Modules\Ecommerce\Filament\Resources')
// In the panel() method
->discoverResources(in: app_path('Filament/Resources'), for: 'App\Filament\Resources')
->discoverResources(in: base_path('Modules/Ecommerce/Filament/Resources'), for: 'Modules\Ecommerce\Filament\Resources')
protected $fillable = [
'name',
'name_it',
'name_en',
'name_fr',
];
Schema::create('products', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('name_it')->nullable();
$table->string('name_en')->nullable();
$table->string('name_fr')->nullable();
$table->timestamps();
});
public static function form(Schema $form): Schema
{
return $form
->schema([
Forms\Components\TextInput::make('name_it')
->label('Name (it)')
->maxLength(255),
Forms\Components\TextInput::make('name_en')
->label('Name (en)')
->maxLength(255),
Forms\Components\TextInput::make('name_fr')
->label('Name (fr)')
->maxLength(255),
Forms\Components\TextInput::make('name')
->
class ProductResource extends Resource
{
protected static ?string $model = Product::class;
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $slug = 'ecommerce/products';
protected static string|UnitEnum|null $navigationGroup = 'Ecommerce';
public static function form(Schema $form): Schema
{
return $form
->schema([
// Campi multilingua generati automaticamente
Forms\Components\TextInput::make('name_it')
->label('Name (it)')
->maxLength(255),
Forms\Components\TextInput::make('name_en')
->label('Name (en)')
->maxLength(255),
Forms\Components\TextInput::make('name')
->ndex' => Pages\ListProducts::route('/'),
'create' => Pages\CreateProduct::route('/create'),
'edit' => Pages\EditProduct::route('/{record}/edit'),
];
}
}
->discoverResources(in: base_path('Modules/Ecommerce/Filament/Resources'), for: 'Modules\Ecommerce\Filament\Resources')
// Nel metodo panel()
->discoverResources(in: app_path('Filament/Resources'), for: 'App\Filament\Resources')
->discoverResources(in: base_path('Modules/Ecommerce/Filament/Resources'), for: 'Modules\Ecommerce\Filament\Resources')
Modules/
├── Ecommerce/
│ ├── app/
│ │ └── Models/
│ │ └── Product.php
│ ├── database/
│ │ └── migrations/
│ │ └── 2026_05_15_201234_create_products_table.php
│ └── Filament/
│ └── Resources/
│ └── Products/ # Plural subdirectory
│ ├── ProductResource.php
│ └── Pages/
│ ├── ListProducts.php
│ ├── CreateProduct.php
│ └── EditProduct.php
bash
# Genera una risorsa in un modulo esistente (default: italiano e inglese)
php artisan module:filament-resource Category Prova
# Genera una risorsa con supporto multilingua specifico
php artisan module:filament-resource Product Ecommerce --languages=it,en,fr,de
# Genera una risorsa in un nuovo modulo (crea automaticamente il modulo)
php artisan module:filament-resource Product Ecommerce --panel=admin
Modules/
├── Ecommerce/
│ ├── app/
│ │ └── Models/
│ │ └── Product.php
│ ├── database/
│ │ └── migrations/
│ │ └── 2026_05_15_201234_create_products_table.php
│ └── Filament/
│ └── Resources/
│ └── Products/ # Sottodirectory plurale
│ ├── ProductResource.php
│ └── Pages/
│ ├── ListProducts.php
│ ├── CreateProduct.php
│ └── EditProduct.php