make-starter-resource
Berikut versi yang dioptimasi untuk AI agent — lebih eksplisit, kontekstual, dan minim ambiguitas:
✨ Feature: make:starter-resource — Custom Filament Resource Generator with Action Pattern
Context for AI Agent
This issue is part of a Laravel + Filament v3 starter kit. The goal is to create a custom Artisan command that generates Filament Resource files using project-specific stubs — integrating the action pattern (as popularized by nunomaduro/laravel-actions or similar single-responsibility action classes).
The generated files must not override or conflict with Filament's built-in make:filament-resource command.
Problem Statement
php artisan make:filament-resource generates standard Filament resource files without any action pattern integration. Developers must manually wire handleRecordCreation and handleRecordUpdate to dedicated Action classes every time. This is repetitive, inconsistent, and not enforced by the starter kit.
Expected Behavior
Running the new command:
php artisan make:starter-resource User
Must produce the following files:
| File | Location |
|---|---|
UserResource.php | app/Filament/Resources/ |
CreateUser.php | app/Filament/Resources/UserResource/Pages/ |
EditUser.php | app/Filament/Resources/UserResource/Pages/ |
CreateUserAction.php | app/Actions/User/ (skip if exists) |
UpdateUserAction.php | app/Actions/User/ (skip if exists) |
Command Specification
Signature:
php artisan make:starter-resource {model}
{--view : Also generate ViewRecord page}
{--soft-deletes : Add soft delete support to stubs}
{--force : Overwrite existing files}
{--namespace= : Override default resource namespace}
{--panel= : Target a specific Filament panel}
Location: app/Console/Commands/MakeStarterResource.php
Stub Specifications
Stub directory:
stubs/starter-kit/resource/
├── create.stub
├── edit.stub
├── view.stub ← only when --view is passed
└── manage.stub
create.stub must render as:
<?php
namespace {{ namespace }}\Pages;
use Illuminate\Database\Eloquent\Model;
use Filament\Resources\Pages\CreateRecord;
use {{ resourceFqn }};
use App\Actions\{{ model }}\Create{{ model }}Action;
class Create{{ model }} extends CreateRecord
{
protected static string $resource = {{ resourceFqn }}::class;
protected function handleRecordCreation(array $data): Model
{
return app(Create{{ model }}Action::class)->handle($data);
}
}
edit.stub must render as:
<?php
namespace {{ namespace }}\Pages;
use Illuminate\Database\Eloquent\Model;
use Filament\Resources\Pages\EditRecord;
use {{ resourceFqn }};
use App\Actions\{{ model }}\Update{{ model }}Action;
class Edit{{ model }} extends EditRecord
{
protected static string $resource = {{ resourceFqn }}::class;
protected function handleRecordUpdate(Model $record, array $data): Model
{
return app(Update{{ model }}Action::class)->handle($record, $data);
}
}
Action stub (action.stub) must render as:
<?php
namespace App\Actions\{{ model }};
use App\Models\{{ model }};
class {{ actionName }}
{
public function handle(array $data): {{ model }}
{
// TODO: implement
}
}
Constraints & Rules
- Do not modify any file under
vendor/or any Filament core class. - Do not register the new command by overriding Filament's command — register it independently in
app/Providers/AppServiceProvider.phpor a dedicated service provider. - Action classes must only be created if the file does not already exist (no
--forceoverride for actions unless explicitly passed). - All stub variables use
{{ double_curly }}syntax, consistent with Laravel's default stub system. - The command must be fully testable — no direct static calls or unresolvable dependencies.
Acceptance Criteria
-
php artisan make:starter-resource Usergenerates all 4 files listed in the expected behavior table - Re-running the command without
--forcedoes not overwrite existing files -
--viewflag generates an additionalViewUser.phppage with no action wiring (view only) -
--soft-deletesflag injects soft delete trait/scope into the resource stub - Generated Action classes are skipped (not overwritten) if already present
- All behavior is covered by Pest tests in
tests/Feature/Console/Commands/MakeStarterResourceTest.php - Usage documented in
README.mdanddocs/11-make-starter-resource.md
Out of Scope
- Generating
form()ortable()column definitions (left to developer) - Generating migrations or model files
- Modifying or wrapping
make:filament-resource