laravel-model-states | State support for models | Architecture library
kandi X-RAY | laravel-model-states Summary
kandi X-RAY | laravel-model-states Summary
State support for models
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Resolve transition not found .
- Thrown when a transition is not allowed .
- Configure package .
- Thrown when a field not found .
- Create transition not found .
- Exception for a transition field .
- Can Transition
- Create a new field does not extend the state class .
laravel-model-states Key Features
laravel-model-states Examples and Code Snippets
Community Discussions
Trending Discussions on laravel-model-states
QUESTION
I'm having an issue when using the model states library from Spatie. I don't think it's a bug but it's not behaving as expected, although only in one of my controllers. We are using the older version of the code and, for now, cannot update to the latest version.
The problem is the "state" field is not being cast to a Spatie\ModelStates\State derived object and is returned as a string. So when I try to transition to a new state I get the exception: "Call to a member function transitionTo() on string".
However, there are other parts of the code where the same model is used and transitions work correctly, with the state being converted to the correct class. I just can't work out why this one controller is causing problems.
States derived from my own abstract class
...ANSWER
Answered 2022-Jan-04 at 14:32The problem was caused by the status
field being filled when the ShiftPattern
was created from the attributes passed in:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install laravel-model-states
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page