observers

Register Eloquent model observers in Laravel app/Observers via observe().

3|Updated Feb 13, 2026
One-click install
npx skills add https://github.com/codebar-ag/coding-guidelines --skill observers
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: observers
Source: https://github.com/codebar-ag/coding-guidelines/tree/main/resources/boost/skills/observers
Command: npx skills add https://github.com/codebar-ag/coding-guidelines --skill observers

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Centralised observers provide reliable side effects by reacting to Laravel Eloquent model lifecycle events, ensuring actions like notifications, cache invalidation, and audit logging occur consistently regardless of where a model changes.

Core Features & Use Cases

  • Observers live in app/Observers and are named after the model they observe with an Observer suffix
  • Register observers in AppServiceProvider using the observe() method
  • Use observers for side effects that should always fire when a model changes
  • Do not place business logic inside observers; use an Action for that

Quick Start

Create an observer class for your model in app/Observers, implement the needed event methods, and register it with AppServiceProvider.

Frequently Asked Questions about observers

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up Laravel Eloquent observers for model lifecycle events?

To set up Laravel Eloquent observers, create observer classes in app/Observers, implement the required model event methods, and register them in AppServiceProvider using the observe() method. This centralizes side effects like notifications and cache invalidation.

What are Eloquent model observers used for in Laravel backend development?

Eloquent model observers are used to trigger reliable side effects when models are mutated. They ensure actions like audit logging, cache invalidation, and notifications fire consistently regardless of where the model changes occur.

When should I not use observers for model events in Laravel?

You should not use observers for core business logic. Observers are specifically for side effects that must always fire when a model changes; complex business operations should be placed inside a dedicated Action instead.

What is the naming convention for Laravel observer classes?

Laravel observer classes should use PascalCase naming and end with an Observer suffix. They must be named after the Eloquent model they observe and placed centrally in the app/Observers directory.

Where do I register Eloquent model observers in a Laravel application?

You register Eloquent model observers in the AppServiceProvider using the observe() method. This ensures the observer classes are properly bound to their respective models globally within the Laravel backend.