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 fix workflow with model id #11

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/Concerns/InteractsWithWorkflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,28 @@ protected function workflows(): \Illuminate\Database\Eloquent\Relations\MorphMan
return $this->morphMany(Workflow::class, 'model');
}

public function getWorkflows()
public function getWorkflows()
{
if ($this->model_id === null) {

//IF I ASSIGN A MODEL_ID TO A WORKFLOW FIRST WAS NOT WORKING FOR ME.

//this is the edit
if ($this->workflows()->exists()) {
return $this->workflows()->get();
}
else {
return Workflow::where('model_id', null)->where('model_type', self::class)->get();
}

return $this->workflows;
//THIS RETURN NULL ALSO IF I ASSIGN A MODEL_ID TO THE WORKFLOW
// if ($this->model_id === null) {
// return Workflow::where('model_id', null)->where('model_type', self::class)->get();
// }

// return $this->workflows;
}


public function getModelTitelForWorkflow(): string
{
return class_basename(self::class);
Expand Down