@@ -52,7 +52,8 @@ class InvestmentZones
|
||||
});
|
||||
}
|
||||
|
||||
/** @param array<string, mixed> $filters */
|
||||
/** @param array<string, mixed> $filters
|
||||
* @return Builder<InvestmentZone> */
|
||||
public function search(array $filters, bool $management = false): Builder
|
||||
{
|
||||
$query = $management ? InvestmentZone::query() : $this->visible();
|
||||
@@ -118,7 +119,7 @@ class InvestmentZones
|
||||
$zone = InvestmentZone::whereKey($id)->lockForUpdate()->firstOrFail();
|
||||
abort_if((int) $zone->version_no !== $version, 409, 'Versão alterada. Recarregue antes de aprovar.');
|
||||
$source = DB::table('investment_legal_sources')->where('id', $zone->legal_source_id)->lockForUpdate()->first();
|
||||
$evidence = is_array($zone->source_evidence) ? $zone->source_evidence : [];
|
||||
$evidence = $zone->source_evidence ?? [];
|
||||
$officialEvidence = collect($evidence)->contains(fn ($item) => in_array($item['source_type'] ?? null, ['government', 'institutional'], true)
|
||||
&& str_starts_with((string) ($item['url'] ?? ''), 'https://') && trim((string) ($item['supports'] ?? '')) !== '');
|
||||
$promoterEvidence = $zone->category === 'industrial_park' && collect($evidence)->contains(fn ($item) => ($item['source_type'] ?? null) === 'promoter'
|
||||
@@ -166,7 +167,7 @@ class InvestmentZones
|
||||
{
|
||||
return DB::transaction(function () use ($id, $version, $actor) {
|
||||
$location = DB::table('investment_zone_locations')->where('id', $id)->lockForUpdate()->first();
|
||||
abort_unless($location, 404);
|
||||
abort_unless($location !== null, 404);
|
||||
abort_if((int) $location->version_no !== $version, 409, 'Version changed.');
|
||||
abort_if((int) $location->editor_id === $actor, 403, 'Independent review required.');
|
||||
abort_unless($location->validation_status === 'pending', 422, 'Territorial association already reviewed.');
|
||||
|
||||
Reference in New Issue
Block a user