Skip to content
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

Models not implementing HasStateMachines trait no longer support having a scopeStatus method. #9

Open
CaptainHilly opened this issue Dec 28, 2020 · 2 comments

Comments

@CaptainHilly
Copy link

Describe the bug
Models that do not implement HasStateMachines, and have a scopeStatus method, will throw a 'call to undefined method status()' exception.

To Reproduce
Steps to reproduce the behavior:

  1. Create ModelA with a scopeStatus method. The method can be a no-op, it doesn't matter.
  2. Create ModelB implementing HasStateMachines.
  3. Try call ModelA::status()->first();
  4. Be sad

Expected behavior
The call to ModelA::status()->first() should not throw a method not found exception.

Solution Ideas
Presume the registering of the status macro in boot of HasStateMachines is causing the issue but not had much of a dig.

Obviously not an issue for new applications making use of this package, but very problematic for existing apps with many models implementing legacy status management, as is the case with our application.

An interim solution for any reader of this Issue is to find/replace all uses of ->status() with something like ->legacyStatus() and change scopeStatus to scopeLegacyStatus.

Love the package BTW. Well done legends!!!

@CaptainHilly
Copy link
Author

If following the interim solution mentioned above, don't forget to find uses of ::status(), cause.... I forgot.... and broke production :-)

@asantibanez
Copy link
Owner

asantibanez commented Dec 28, 2020

Hey @CaptainHilly ! Thank you for trying out the package.

Yes! I am aware of the status() issue. I've ran into the same problem myself. I am thinking of adding a prefix/suffix to these helper methods that can be customized via config. Eg: suffix => 'StateMachine', method statusStateMachine()

How does that sound to you?

Be careful with production! 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants