What are Eloquent Model Observers?
Why Interviewers Ask This
This tests whether you can apply Laravel knowledge to real-world scenarios. Interviewers are looking for clarity of thought and evidence that you've encountered this in production code.
Answer
Observers group event listeners for a single model into a dedicated class. Create: php artisan make:observer UserObserver --model=User. The observer class has methods for each Eloquent event: creating(), created(), updating(), updated(), saving(), saved(), deleting(), deleted(), restoring(), restored(). Register in the model with the ObservedBy attribute (#[ObservedBy(UserObserver::class)]) or in a service provider: User::observe(UserObserver::class). Example use: automatically hashing passwords on creating, sending welcome emails on created, updating a search index on saved, logging deletes on deleted. Observers are cleaner than model event closures for complex logic.
Pro Tip
This topic has Laravel-specific nuances that differ from general programming. Highlighting those nuances in your answer shows expertise rather than generic knowledge.