Laravel attributes
Skill fusengine/agents/plugins/laravel-expert/skills/laravel-attributes
Use when migrating Eloquent models, Jobs, Console commands, Controllers, API Resources, Validation, Factories or Seeders to native PHP 8.3 attributes introduced in Laravel 13. Covers all 7 categories of first-party attributes.From its SKILL.md
npx -y skills add fusengine/agents --skill laravel-attributesAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 22 stars22 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
5.8 KB, ~1.3k tokens by cl100k_base, as published. Nobody here has run it
Laravel 13 PHP Attributes
Agent Workflow (MANDATORY)
Before ANY implementation, use TeamCreate to spawn 3 agents:
- fuse-ai-pilot:explore-codebase - Scan existing models/jobs/controllers for legacy
protected $fillable / $hidden / $connectionproperties to convert - fuse-ai-pilot:research-expert - Verify Laravel 13 release notes for attribute coverage and edge cases
- mcp__context7__query-docs - Pull authoritative examples from
laravel.com/docs/13.x
After implementation, run fuse-ai-pilot:sniper for validation.
Overview
| Category | Attributes |
|---|---|
| Eloquent | #[Table] #[Connection] #[Fillable] #[Hidden] #[Visible] #[Guarded] #[Unguarded] #[Appends] #[Touches] |
| Queue / Job | #[Connection] #[Queue] #[Tries] #[Timeout] #[Backoff] #[MaxExceptions] #[FailOnTimeout] #[UniqueFor] |
| Console | #[Signature] #[Description] |
| Controllers | #[Middleware] #[Authorize] |
| Validation | #[RedirectTo] #[StopOnFirstFailure] |
| API Resources | #[Collects] #[PreserveKeys] |
| Factories / Seeders | #[UseModel] #[Seed] #[Seeder] |
Critical Rules
- NEVER mix attributes and legacy properties -
#[Fillable(['name'])]+protected $fillable = [...]causes Laravel to ignore the attribute silently - Class-level only - All Eloquent / Job / Controller attributes apply to the class, never to private/protected methods
- Single source of truth - Choose attributes OR properties per class; refactor in one pass to avoid drift
- Inheritance is additive - Child class attributes merge with parent attributes; redeclare to override
- Import the right namespace -
Illuminate\Database\Eloquent\Attributes\*for Eloquent,Illuminate\Queue\Attributes\*for Jobs
Architecture
app/
├── Models/
│ └── User.php # #[Table] #[Fillable] #[Hidden] #[Appends]
├── Jobs/
│ └── ProcessPodcast.php # #[Connection] #[Queue] #[Tries] #[Backoff]
├── Console/Commands/
│ └── SendEmails.php # #[Signature] #[Description]
├── Http/
│ ├── Controllers/
│ │ └── PostController.php # #[Middleware] #[Authorize]
│ └── Resources/
│ └── PostCollection.php # #[Collects] #[PreserveKeys]
└── Http/Requests/
└── StoreUserRequest.php # #[RedirectTo] #[StopOnFirstFailure]
→ See Model-with-attributes.php.md for full example
Reference Guide
| Topic | Reference | When to Consult |
|---|---|---|
| Eloquent models | eloquent.md | Migrating $fillable / $hidden / $table / $connection |
| Queue jobs | queue.md | Replacing $tries / $timeout / $backoff properties |
| Console commands | console.md | Refactoring $signature / $description properties |
| Controllers | controllers.md | Moving middleware/authorize from constructors |
| Validation | validation.md | FormRequest redirect + early-stop config |
| API Resources | api-resources.md | Collection wrapping and key preservation |
| Factories / Seeders | factories-seeders.md | Model binding and seeder discovery |
Templates
| Template | When to Use |
|---|---|
| Model-with-attributes.php.md | Net new Eloquent model |
| Job-with-attributes.php.md | Net new queue Job |
Quick Reference
Eloquent model
use Illuminate\Database\Eloquent\Attributes\{Table, Fillable, Hidden, Appends};
#[Table('flights')]
#[Fillable(['name', 'origin'])]
#[Hidden(['password'])]
#[Appends(['is_admin'])]
class Flight extends Model {}
Queue job
use Illuminate\Queue\Attributes\{Connection, Queue, Tries, Backoff};
#[Connection('redis')]
#[Queue('podcasts')]
#[Tries(5)]
#[Backoff([10, 30, 60])]
class ProcessPodcast implements ShouldQueue {}
→ See Job-with-attributes.php.md for complete example
Best Practices
DO
- Convert one class at a time and run tests between commits
- Keep attribute imports grouped at the top via PHP 8.1 grouped
usesyntax - Use
#[Fillable]for mass-assigned models and#[Unguarded]only on trusted internal models - Combine
#[Connection]+#[Queue]on Jobs to centralize routing intent
DON'T
- Don't mix
#[Fillable(['x'])]withprotected $fillable = ['y']- the property silently wins on some setups, the attribute on others - Don't place Eloquent/Job attributes on methods - they target the class only
- Don't put
#[Authorize]on a controller without an underlying Policy registered inAuthServiceProvider - Don't forget to drop the legacy
$tries,$backoff,$timeoutproperties after adding the attributes - duplication is a red flag for code review
What ships with it: 9 files
13.6 KB alongside SKILL.md
references/
- api-resources.md1.2 KB
- console.md1.1 KB
- controllers.md1.4 KB
- eloquent.md2.2 KB
- factories-seeders.md1.5 KB
- queue.md2.0 KB
- templates/Job-with-attributes.php.md1.6 KB
- templates/Model-with-attributes.php.md1.5 KB
- validation.md1.3 KB