scaffold-observer

📁 iurygdeoliveira/labsis-kit 📅 Jan 24, 2026
3
总安装量
3
周安装量
#60497
全站排名
安装命令
npx skills add https://github.com/iurygdeoliveira/labsis-kit --skill scaffold-observer

Agent 安装分布

claude-code 2
windsurf 1
trae 1
opencode 1
codex 1
antigravity 1

Skill 文档

Laravel Observer Pattern Skill

Use this skill when you need to trigger logic based on Eloquent Model events (created, updated, deleted, etc.).

When to use

  • Sending emails after user registration.
  • Logging changes for audit entry.
  • Updating summary tables.

Rules

1. Silent Handling

  • Observers should handle exceptions gracefully or let them bubble up depending on criticality.
  • Avoid putting slow blocking logic (like API calls) directly in Observer. Dispatch a Job/Event instead.

2. Registration

  • Ensure the Observer is registered in the model attribute #[ObservedBy(UserObserver::class)] (Laravel 10+ standard) or in AppServiceProvider.
  • Prefer Attributes:
#[ObservedBy(UserObserver::class)]
class User extends Authenticatable
{
    // ...
}

3. Methods

  • Type hint the model in the observer methods.
public function created(User $user): void
{
    // ...
}