Entrega dashboard e correccoes transversais preservando Ofertas instalado
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -245,6 +245,30 @@ final class InvestmentGeography
|
||||
return $path;
|
||||
}
|
||||
|
||||
/** Canonical selection for a place-of-interest filter, including legacy links.
|
||||
* @param array<string,mixed> $filters
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
public function interestSelection(array $filters): array
|
||||
{
|
||||
$location = \Illuminate\Support\Facades\Validator::make($filters, ['territory' => 'nullable|uuid', 'province_id' => 'nullable|uuid', 'district_id' => 'nullable|uuid', 'admin_post_id' => 'nullable|uuid', 'locality_id' => 'nullable|uuid'])->validate();
|
||||
if (array_intersect(array_keys(self::FIELDS), array_keys($location))) {
|
||||
$path = $this->selection($location);
|
||||
$territory = $path ? $path[array_key_last($path)]->id : null;
|
||||
if (! empty($location['territory']) && $location['territory'] !== $territory) {
|
||||
throw ValidationException::withMessages(['territory' => 'O local de interesse não corresponde à hierarquia seleccionada.']);
|
||||
}
|
||||
if ($territory) $filters['territory'] = $territory;
|
||||
else unset($filters['territory']);
|
||||
}
|
||||
if (! empty($filters['territory'])) {
|
||||
$path = $this->path($filters['territory']);
|
||||
if (! $path) throw ValidationException::withMessages(['territory' => 'Seleccione um local disponível no cadastro.']);
|
||||
foreach ($path as $node) $filters[$node->location_type.'_id'] = $node->id;
|
||||
}
|
||||
return $filters;
|
||||
}
|
||||
|
||||
/** @return list<string> */
|
||||
public function descendants(string $id, bool $includeNonPublic = false): array
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user