make(Kernel::class)->bootstrap(); require getenv('IR_CANDIDATE_ROOT').'/integrations/sgf/internal-requisitions/bootstrap.php'; $row = DB::table('ir_requests')->orderBy('id')->first(); $actor = User::findOrFail($row->requester_id); auth()->guard()->setUser($actor); app(CompanyContext::class)->selectFor($actor->id, $row->tenant_id, $row->company_id, $row->unit_id); request()->headers->set('X-Purchasing-Context', 'procurement.internal'); $record = (new InternalRequisitions(new Port($actor)))->view($row->id); if ($record['status'] !== 'approved' || $record['origin_key'] !== $row->origin_key) { throw new RuntimeException('Restored process cannot be consulted.'); } echo json_encode(['restored_candidate_consultation' => true, 'id' => $record['id'], 'origin_preserved' => true, 'version' => $record['version']], JSON_THROW_ON_ERROR)."\n";