New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.6] Register many observers for a model #23507

merged 4 commits into from Mar 13, 2018


None yet
6 participants

Alymosul commented Mar 12, 2018

This PR adds the ability to pass an array of observers to the observe() method for a model instead of registering each of them one by one.
Consider we have a Thread model and we will register the following observers for it: DeleteThreadRepliesObserver, GenerateThreadSlugObserver, ReputationObserver, ThreadObserver


This comment has been minimized.


ntzm commented Mar 13, 2018

This is nice, I've definitely needed this before! However, could you possibly add tests? Thanks


This comment has been minimized.


devcircus commented Mar 13, 2018

I second this. Though I personally no longer use observers in most cases. It makes sense. Tests would be nice.


This comment has been minimized.

ludo237 commented Mar 13, 2018

@devcircus is there a better alternative to observers?

@Alymosul I think you should add tests in order to verify that someone can actually use the old version and the new one

Alymosul added some commits Mar 13, 2018

@taylorotwell taylorotwell merged commit 4f8bc0e into laravel:5.6 Mar 13, 2018

2 checks passed

continuous-integration/styleci/pr The StyleCI analysis has passed
continuous-integration/travis-ci/pr The Travis CI build passed

This comment has been minimized.


afraca commented Mar 14, 2018

Nice addition.
Nitpick: I know this is already merged, but perhaps we could make the registerObserver method protected to be in line with the rest of the model and be easier to override?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment