feat: consolidar desenvolvimentos do portal InvestMoz

This commit is contained in:
2026-11-03 23:32:32 +02:00
parent 1da273f1f3
commit 36c8cadb49
345 changed files with 110714 additions and 2799 deletions
@@ -0,0 +1,28 @@
<?php
namespace App\Services;
use App\Models\Opportunity;
use App\Models\User;
/** Observe technical failures without changing the approved transition engine. */
final class OpportunityWorkflowExecution
{
public function __construct(private OpportunityProfileWorkflow $workflow, private OpportunityTechnicalExecution $execution) {}
/** @param array<string,mixed> $input */
public function transition(User $actor, int $id, array $input): Opportunity
{
$action = $input['action'] ?? null;
if (! in_array($action, ['submit', 'publish'], true)) {
return $this->workflow->transition($actor, $id, $input);
}
$record = Opportunity::withTrashed()->findOrFail($id);
app(PortalProfileAccess::class)->authorize($actor, 'view', $record);
if (! in_array($action, $this->workflow->actions($actor, $record), true)) {
return $this->workflow->transition($actor, $id, $input);
}
return $this->execution->run($actor, $record, $action, $input, fn () => $this->workflow->transition($actor, $id, $input));
}
}