47 lines
1009 B
PHP
47 lines
1009 B
PHP
<?php
|
|
|
|
namespace Modules\ApprovalWorkflow\Models;
|
|
|
|
use App\Models\User;
|
|
use App\Traits\HasPublicIdentifier;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Modules\ApprovalWorkflow\Enums\ApprovalStepStatus;
|
|
|
|
class ApprovalStep extends Model
|
|
{
|
|
use HasPublicIdentifier;
|
|
|
|
protected $fillable = [
|
|
'approval_chain_id',
|
|
'approver_id',
|
|
'order',
|
|
'status',
|
|
'notes',
|
|
'acted_at',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'status' => ApprovalStepStatus::class,
|
|
'acted_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
public function chain(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ApprovalChain::class, 'approval_chain_id');
|
|
}
|
|
|
|
public function approver(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'approver_id');
|
|
}
|
|
|
|
public function isPending(): bool
|
|
{
|
|
return $this->status === ApprovalStepStatus::Pending;
|
|
}
|
|
}
|