20 lines
454 B
PHP
20 lines
454 B
PHP
<?php
|
|
|
|
namespace Modules\Workflow\Concerns;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
|
use Modules\Workflow\Models\WorkflowInstance;
|
|
|
|
trait HasWorkflow
|
|
{
|
|
public function workflowInstance(): MorphOne
|
|
{
|
|
return $this->morphOne(WorkflowInstance::class, 'subject');
|
|
}
|
|
|
|
public function workflowLabel(): string
|
|
{
|
|
return (string) ($this->title ?? $this->name ?? class_basename($this).' #'.$this->getKey());
|
|
}
|
|
}
|