TenantAtlas/apps/platform/app/Models/ReviewPublicationResolutionStep.php
ahmido ba7622a158 feat: implement ReviewPublicationResolutionWorkflow (Spec 386) (#457)
## Summary\n- Implements the ReviewPublicationResolutionWorkflow for Spec 386.\n- Adds resolution case/step persistence, policies, services, audit action IDs, and Filament integration.\n- Updates specs, UI/UX documentation, screenshots, and Pest coverage.\n\n## Tests\n- Not run during this handoff; branch was already clean and pushed.\n\n## Target\n- Base: platform-dev\n- Head/topic: 386-review-publication-resolution-workflow-v1

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #457
2026-06-18 21:06:20 +00:00

84 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Models;
use App\Support\ReviewPublicationResolution\ReviewPublicationResolutionStepKey;
use App\Support\ReviewPublicationResolution\ReviewPublicationResolutionStepStatus;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class ReviewPublicationResolutionStep extends Model
{
protected $guarded = [];
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'summary' => 'array',
'metadata' => 'array',
'position' => 'integer',
'started_at' => 'datetime',
'completed_at' => 'datetime',
'failed_at' => 'datetime',
'superseded_at' => 'datetime',
];
}
/**
* @return BelongsTo<ReviewPublicationResolutionCase, $this>
*/
public function case(): BelongsTo
{
return $this->belongsTo(ReviewPublicationResolutionCase::class, 'case_id');
}
/**
* @return BelongsTo<OperationRun, $this>
*/
public function operationRun(): BelongsTo
{
return $this->belongsTo(OperationRun::class);
}
public function statusEnum(): ReviewPublicationResolutionStepStatus
{
return ReviewPublicationResolutionStepStatus::tryFrom((string) $this->status)
?? ReviewPublicationResolutionStepStatus::Pending;
}
public function stepKeyEnum(): ?ReviewPublicationResolutionStepKey
{
return ReviewPublicationResolutionStepKey::tryFrom((string) $this->step_key);
}
/**
* @return array{type:string,id:int}|null
*/
public function proofReference(): ?array
{
if (! is_string($this->proof_type) || $this->proof_type === '' || ! is_numeric($this->proof_id)) {
return null;
}
return [
'type' => $this->proof_type,
'id' => (int) $this->proof_id,
];
}
/**
* @param Builder<self> $query
* @return Builder<self>
*/
public function scopeOrdered(Builder $query): Builder
{
return $query->orderBy('position')->orderBy('id');
}
}