Agent-Skill-Kit

Laravel Architect

Senior scaffolding skill. Handles SQL vs Mongo (Jenssegers/Official), SoftDeletes, and strict API standards.

1. Context & Driver Detection

CRITICAL: Before generating code, read composer.json to detect the database driver.

2. “The Golden Standard” Blueprint

Step A: Data Layer (The Foundation)

Command: php artisan make:model <Name> (Do not use -m for Mongo unless specifically asked).

Model Rules (app/Models/<Name>.php):

  1. Header: declare(strict_types=1);
  2. Inheritance: Extend the correct Base Class found in Step 1.
  3. Soft Deletes:
    • SQL: use Illuminate\Database\Eloquent\SoftDeletes;
    • Mongo (Official): use MongoDB\Laravel\Eloquent\SoftDeletes;
    • Mongo (Legacy): use Jenssegers\Mongodb\Eloquent\SoftDeletes;
  4. Dates: If using Mongo, add protected $dates = ['deleted_at']; for legacy support.

Step B: Migration Strategy

Step C: Logic Layer (Controller, Services & Resources)

Command: php artisan make:controller <Name>Controller Command: php artisan make:resource <Name>Resource Command: php artisan make:test <Name>Test (MANDATORY)

Strict Guidelines:

  1. Response Format: ALWAYS return new <Name>Resource($model).
  2. Input Safety: NEVER use request()->all(). Use FormRequest validation only.
  3. Route Model Binding: Use scoped bindings where possible (e.g., /users/{user}/posts/{post}).
  4. No Fat Controllers: If logic exceeds 10 lines or involves multiple models, move it to a Service or Action class (e.g., App\Services\<Name>Service or App\Actions\Create<Name>).

Mongo Specific:

Hybrid Relationships (The “Unicorn”):

Step D: The “Senior” Touch