move into sonardesk
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Workflow\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
final class WorkflowDefinition extends Model
|
||||
{
|
||||
protected $fillable = ['name', 'slug', 'description', 'subject_type', 'is_active'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return ['is_active' => 'boolean'];
|
||||
}
|
||||
|
||||
public function stages(): HasMany
|
||||
{
|
||||
return $this->hasMany(WorkflowStage::class)->orderBy('position');
|
||||
}
|
||||
|
||||
public function transitions(): HasMany
|
||||
{
|
||||
return $this->hasMany(WorkflowTransition::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Workflow\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
final class WorkflowHistory extends Model
|
||||
{
|
||||
protected $table = 'workflow_history';
|
||||
|
||||
protected $fillable = ['workflow_instance_id', 'from_stage_id', 'to_stage_id', 'user_id', 'action', 'comment', 'metadata'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return ['metadata' => 'array'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Workflow\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
final class WorkflowInstance extends Model
|
||||
{
|
||||
protected $fillable = ['workflow_definition_id', 'workflow_stage_id', 'subject_type', 'subject_id', 'status', 'started_by', 'assigned_to', 'due_at', 'completed_at'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return ['due_at' => 'datetime', 'completed_at' => 'datetime'];
|
||||
}
|
||||
|
||||
public function definition(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WorkflowDefinition::class, 'workflow_definition_id');
|
||||
}
|
||||
|
||||
public function stage(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WorkflowStage::class, 'workflow_stage_id');
|
||||
}
|
||||
|
||||
public function subject(): MorphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
public function history(): HasMany
|
||||
{
|
||||
return $this->hasMany(WorkflowHistory::class)->latest();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Workflow\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
final class WorkflowStage extends Model
|
||||
{
|
||||
protected $fillable = ['workflow_definition_id', 'name', 'slug', 'position', 'required_permission', 'is_initial', 'is_terminal', 'allows_rejection', 'due_days'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return ['is_initial' => 'boolean', 'is_terminal' => 'boolean', 'allows_rejection' => 'boolean'];
|
||||
}
|
||||
|
||||
public function definition(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WorkflowDefinition::class, 'workflow_definition_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Workflow\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
final class WorkflowTransition extends Model
|
||||
{
|
||||
protected $fillable = ['workflow_definition_id', 'from_stage_id', 'to_stage_id', 'name', 'action', 'required_permission', 'requires_comment'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return ['requires_comment' => 'boolean'];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user