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

[Bug]: #4

Open
ramonov opened this issue Jan 16, 2024 · 2 comments
Open

[Bug]: #4

ramonov opened this issue Jan 16, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@ramonov
Copy link

ramonov commented Jan 16, 2024

What happened?

I tried to extend the existing trait HasState to get the list of history of transaction for specific model. here is the function that i added:

 use HasState;
    public function getStateHistory()
    {
        //$self = self::class;
        $workflow = $this->currentWorkflow();
        $id=$this->getId();
        $collection = StateTransition::select('arflow_state_transitions.id', 'arflow_state_transitions.to as to','arflow_state_transitions.created_at','arflow_state_transitions.comment','arflow_state_transitions.Actor_model_id','arflow_state_transitions.actor_model_type','emp.first_name','emp.middle_name','emp.last_name')
                        ->leftjoin('employees as emp', 'emp.id', '=', 'arflow_state_transitions.actor_model_id')
                        ->where('workflow', $workflow)
                        ->where('model_id', $id)->get();

        $history = $collection->each(function($item){
            $parts = [$item->first_name, $item->middle_name, $item->last_name];
            $item->name = implode(" ",array_filter($parts, function ($part) {
                return !is_null($part) && $part !== '';
            }));
            unset($item->first_name);
            unset($item->middle_name);
            unset($item->last_name);
        });    
        
        return $history;
        
    }

but i am not able to get the exact result using :
$model = $model->findOrFail($this->editingId);
$history = $model->getStateHistory();

i am getting following error:
Typed property AuroraWebSoftware\ArFlow\StateTransition::$comment must not be accessed before initialization

is there any way to get the list of transition history from transition log table?

How to reproduce the bug

add above extended trait and try to access the getStateHistory method to extract the log history related to model.

Package Version

1.0.2

PHP Version

8.2

Laravel Version

10

Which operating systems does with happen with?

No response

Notes

Appreciate your help. I found only this feature is missing for this model. other wise every thing works like charm.

thanks

@ramonov ramonov added the bug Something isn't working label Jan 16, 2024
@emreakay
Copy link
Contributor

@ramonov thans for your bug report,
we will be resolving the issue on v 1.2.x.

@ramonov
Copy link
Author

ramonov commented Apr 4, 2024

Thanks for considering my request. Basically missing part was access flow history. Which will be needed frequently to show the history of flow to users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants