Carteira 4.3: ficha sem ligações mostra oportunidades da mesma província e sector, indicadas como não ligadas

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzJmxFy3izprXr5dSq91jM
This commit is contained in:
Claude
2026-12-05 11:01:59 +02:00
committed by nala
parent 0556d15e37
commit e6888e790f
4 changed files with 167 additions and 2 deletions
@@ -16,6 +16,7 @@ use App\Services\InvestmentRelations;
use App\Services\InvestmentZones;
use App\Services\PortalAudit;
use App\Services\PortalEditorialWorkflow;
use App\Services\PortfolioNearbyOpportunities;
use App\Services\PublicSearchMetrics;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Query\Builder as QueryBuilder;
@@ -179,6 +180,7 @@ class InvestmentPortfolioController extends Controller
$anchorProject = $record->project_id
? Project::whereKey($record->project_id)->whereNull('deleted_at')->where('status', '!=', 'draft')->first(['id', 'code', 'name', 'status', 'budget_amount', 'budget_currency', 'start_date', 'end_date'])
: null;
$geography = app(InvestmentRelations::class)->dossier($record, $management);
$existingSubmissions = ! $management && $request->user()
? InvestmentSubmission::where('user_id', $request->user()->id)->where('dossier_id', $record->id)->where('status', 'draft')
->orderByDesc('updated_at')->limit(10)->get(['id', 'version', 'updated_at'])
@@ -187,7 +189,9 @@ class InvestmentPortfolioController extends Controller
return Inertia::render('portfolio/show', ['publicReferenceNames' => $management ? [] : $this->publicReferenceNames(), 'editorialEnabled' => $editorial, 'complements' => $management ? [] : app(InvestmentComplements::class)->options('portfolio:'.$record->id), 'record' => $record, 'related' => $related, 'management' => $management, 'zones' => $zones,
'anchorProject' => $anchorProject, 'existingSubmissions' => $existingSubmissions,
'competitiveness' => $record->cluster_id ? app(ClusterCompetitiveness::class)->publicData($record->cluster_id) : null,
'geography' => app(InformationGaps::class)->annotate($record->id, app(InvestmentRelations::class)->dossier($record, $management)),
'geography' => app(InformationGaps::class)->annotate($record->id, $geography),
// Carteira 4.3: with nothing linked, show same-province/same-sector opportunities, labelled as not linked.
'nearby' => $opportunities->isEmpty() ? app(PortfolioNearbyOpportunities::class)->for($record, $geography, []) : null,
'origin' => $origin ? ['id' => $origin->id, 'title' => $origin->title] : null, 'opportunities' => $opportunities, 'chains' => $chains]);
}