Skip to content

[Bug]:  #4

@ramonov

Description

@ramonov

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions