versao compilada 1
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-16 09:17:28 +02:00
parent c13f250b87
commit 6a76aac80f
901 changed files with 253428 additions and 252 deletions
@@ -2,8 +2,10 @@
namespace App\Http\Controllers;
use App\Services\FintechInvestment;
use App\Services\InvestorPath;
use App\Services\LegacyContent;
use App\Services\SectorInvestment;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
@@ -21,21 +23,45 @@ class InvestorPathController extends Controller
return $request->expectsJson() ? response()->json($data) : Inertia::render('investor-path/index', $data);
}
public function sectorStart(Request $request, string $sectorSlug, InvestorPath $path): JsonResponse|Response
{
abort_unless($path->available(), 404);
$data = ['contexts' => $path->contexts($request->user()), 'sectorSource' => app(SectorInvestment::class)->context($sectorSlug)];
return $request->expectsJson() ? response()->json($data) : Inertia::render('investor-path/index', $data);
}
public function sectorAttach(Request $request, string $id): JsonResponse|RedirectResponse
{
app(SectorInvestment::class)->attach($request->user(), $id, $request->all());
return $request->expectsJson() ? response()->json(['ok' => true]) : redirect('/investimentos/'.$id)->with('success', 'Setor associado ao mesmo dossier.');
}
public function create(Request $request, InvestorPath $path): JsonResponse|RedirectResponse
{
$sector = $request->validate(['sector_slug' => 'nullable|string|max:150'])['sector_slug'] ?? null;
if ($sector !== null) {
app(SectorInvestment::class)->context($sector);
}
$source = $request->input('content_resource_id');
if ($source !== null) {
$resourceId = filter_var($source, FILTER_VALIDATE_INT);
abort_unless(is_int($resourceId) && $resourceId !== 0, 422);
app(LegacyContent::class)->articleForResource($resourceId);
}
$id = DB::transaction(function () use ($path, $request, $source): string {
$id = DB::transaction(function () use ($path, $request, $source, $sector): string {
$id = $path->create($request->user(), $request->all());
if ($source !== null) {
$case = $path->view($request->user(), $id)['case'];
app(LegacyContent::class)->attach($request->user(), $id, ['version' => $case['version'], 'resource_id' => (int) $source]);
}
if ($sector !== null) {
$case = $path->view($request->user(), $id)['case'];
app(SectorInvestment::class)->attach($request->user(), $id, ['version' => $case['version'], 'sector_slug' => $sector]);
}
return $id;
});
@@ -80,6 +106,14 @@ class InvestorPathController extends Controller
return $request->expectsJson() ? response()->json(['id' => $task], 201) : back()->with('success', 'Tarefa assumida no acompanhamento interno.');
}
public function fintech(Request $request, string $id, InvestorPath $path): JsonResponse|RedirectResponse
{
abort_unless($path->available(), 404);
app(FintechInvestment::class)->save($request->user(), $id, $request->all());
return $this->saved($request, 'Caracterização Fintech guardada no mesmo dossier; pendências e histórico preservados.');
}
private function saved(Request $request, string $message): JsonResponse|RedirectResponse
{
return $request->expectsJson() ? response()->json(['message' => $message]) : back()->with('success', $message);