Generates modular Filament resources following Laravel HRMS conventions with HasUuid trait, enum support, and organized field grouping
Enforce modular Filament resource structure for Laravel applications with strict conventions for models, enums, UUIDs, and organized field grouping.
All Eloquent models MUST include:
1. **Universal Fields**:
- `id` (Primary Key, auto-incrementing)
- `uuid` (Universally Unique Identifier)
- `created_at` and `updated_at` (Laravel timestamps)
2. **HasUuid Trait**:
```php
use App\Traits\HasUuid;
class YourModel extends Model
{
use HasUuid;
}
```
3. **Enum Usage**:
- Store enums in `App\Enums`
- Always type-cast in model:
```php
protected $casts = [
'status' => \App\Enums\StatusEnum::class,
];
```
Before generating resources:
1. Read the target model file from `app/Models/<ModelName>.php`
2. Extract:
- Fillable fields
- Cast definitions (especially enums)
- Relationships
- Nullable columns from migration or database
3. Group logically related fields (e.g., "Basic Info", "Contact Info", "Account Settings")
**MANDATORY**: Use the custom Artisan command, NOT the default `make:filament-resource`:
```bash
php artisan make:modular-filament-resource <ModelName> --fields="GroupOne,GroupTwo,GroupThree" [--generate] [--model] [--migration]
```
**Example**:
```bash
php artisan make:modular-filament-resource User --fields="Basic Info,Personal Info,Account Settings,Contact Info"
```
Expected output for a `User` model:
```
app/Filament/Resources/
├── UserResource.php
└── UserResource/
├── FormSchema.php
├── TableSchema.php
├── Actions.php
└── Fields/
├── BasicInfo.php
├── PersonalInfo.php
├── AccountSettings.php
└── ContactInfo.php
```
Each group file must:
**Example** (`Fields/BasicInfo.php`):
```php
namespace App\Filament\Resources\UserResource\Fields;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\TextInput;
class BasicInfo
{
public static function make(): Section
{
return Section::make('Basic Info')
->schema([
TextInput::make('name')->required(),
TextInput::make('email')->email()->required(),
])
->columns(2);
}
}
```
Rules for table columns:
**Example**:
```php
use Filament\Tables\Columns\TextColumn;
TextColumn::make('email')
->toggleable()
->hidden(),
TextColumn::make('phone')
->toggleable()
->hidden(),
TextColumn::make('created_at')
->dateTime()
->toggleable(),
```
Centralize all table actions:
```php
namespace App\Filament\Resources\UserResource;
use Filament\Tables\Actions;
class Actions
{
public static function getActions(): array
{
return [
Actions\EditAction::make(),
Actions\DeleteAction::make(),
];
}
public static function getBulkActions(): array
{
return [
Actions\BulkActionGroup::make([
Actions\DeleteBulkAction::make(),
]),
];
}
}
```
Reference in resource:
```php
->actions(Actions::getActions())
->bulkActions(Actions::getBulkActions())
```
**DO NOT**:
**DO**:
| Element | Location | Requirements |
|---------|----------|--------------|
| Model | `app/Models/` | HasUuid trait, id/uuid/timestamps, enum casts |
| Resource | `app/Filament/Resources/` | Minimal, references external schemas |
| Field Groups | `Resources/<Model>/Fields/` | Section::make() with grouped fields |
| Table Schema | `Resources/<Model>/TableSchema.php` | Toggleable columns, hidden if nullable |
| Actions | `Resources/<Model>/Actions.php` | getActions() and getBulkActions() methods |
```bash
php artisan make:modular-filament-resource Employee --fields="Personal Info,Employment Details,Contact Info,Emergency Contacts" --generate
```
This modular approach ensures clean, maintainable, and scalable Filament resources ready for future microservice conversion.
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/filament-hrms-modular-resource-generator/raw