laravel-eloquent-state-machines
laravel-eloquent-state-machines copied to clipboard
Get possible states for a given state
Summary
What's the new feature about? What should it do?
return [
'pending' => ['approved', 'declined'],
'approved' => ['processed'],
];
I need to know which states are allowed to be executed for a given state, Something like this: array = $model->status->allowedStatesToBeAppliedOn('approved'); // => this gives ['processed']
Additional Notes
This may be usefull for UI/UX, when we view a model record, we may show a button actions to perform one of its allowed states to be applied.
Thanks
As a solution for me, I did this in my model :
public function allowedStates()
{
return $this->status()->stateMachine()->transitions()[$this->status];
}