Skip to content

feat: Observable Model Properties (#[Watches] attribute system)#241

Merged
techmahedy merged 1 commit intodoppar:3.xfrom
techmahedy:techmahedy-3.x
Apr 14, 2026
Merged

feat: Observable Model Properties (#[Watches] attribute system)#241
techmahedy merged 1 commit intodoppar:3.xfrom
techmahedy:techmahedy-3.x

Conversation

@techmahedy
Copy link
Copy Markdown
Member

This PR introduces Observable Model Properties — a property-level reactive observation system for Doppar models, implemented via the #[Watches] attribute.

When a watched model property is dirty at save() or update() time, the framework automatically resolves the registered watcher from the DI container and calls its handle($old, $new, $model) method. An optional when condition (either a model method or a class implementing WatchConditionInterface) controls whether the listener fires.

A make:watcher console command scaffolds new watcher listener classes into app/Watchers/.

Example

#[Watches(EmployeeStatusWatcher::class, when: 'isFraudRisk')]
protected bool $status;

public function isFraudRisk(): bool
{
      return true;
}

@techmahedy techmahedy added the feat new feature label Apr 14, 2026
@techmahedy techmahedy merged commit caebb42 into doppar:3.x Apr 14, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant