@extends('layouts.app')
@section('title', !empty($displayName) ? strtoupper($displayName) . ' ' . ($activeFilter !== 'all' ? ucwords(str_replace('-', ' ', $activeFilter)) . ' ' : '') . 'Planning Information & Restrictions' : 'Search Planning Data')
@section('meta_description', !empty($displayName) ? 'Explore ' . ($activeFilter !== 'all' ? str_replace('-', ' ', $activeFilter) : 'planning constraints, heritage protections, and future development restrictions') . ' for ' . strtoupper($displayName) . '.' : 'Search for planning constraints and datasets by UK location.')
@section('content')
@if ($error)
@endif
@if (!empty($query) && !$error)
{{ isset($results['count']) ? $results['count'] : (isset($results['entities']) ? count($results['entities']) : 0) }}
matching entities
@php
$filterButtons = [
'all' => 'bg-gray-100 text-gray-800 ring-gray-600/20',
'planning-applications' => 'bg-blue-100 text-blue-800 ring-blue-600/20',
'listed-building' => 'bg-amber-100 text-amber-800 ring-amber-600/20',
'conservation-area' => 'bg-emerald-100 text-emerald-800 ring-emerald-600/20',
'flood-risk-zone' => 'bg-cyan-100 text-cyan-800 ring-cyan-600/20',
'tree-preservation-orders' => 'bg-lime-100 text-lime-800 ring-lime-600/20',
'article-4-directions' => 'bg-red-100 text-red-800 ring-red-600/20',
'brownfield-sites' => 'bg-orange-100 text-orange-800 ring-orange-600/20',
'scheduled-monument' => 'bg-stone-100 text-stone-800 ring-stone-600/20',
'site-of-special-scientific-interest' => 'bg-teal-100 text-teal-800 ring-teal-600/20',
'ancient-woodland' => 'bg-fuchsia-100 text-fuchsia-800 ring-fuchsia-600/20',
'heritage-at-risk' => 'bg-rose-100 text-rose-800 ring-rose-600/20',
'area-of-outstanding-natural-beauty' => 'bg-sky-100 text-sky-800 ring-sky-600/20',
'local-plan-boundary' => 'bg-indigo-100 text-indigo-800 ring-indigo-600/20',
'developer-agreement' => 'bg-violet-100 text-violet-800 ring-violet-600/20',
'community-infrastructure-levy-schedule' => 'bg-purple-100 text-purple-800 ring-purple-600/20',
'infrastructure-funding-statement' => 'bg-pink-100 text-pink-800 ring-pink-600/20',
'design-code-area' => 'bg-slate-100 text-slate-800 ring-slate-600/20',
];
$badgeColors = [
'all' => 'bg-gray-100 text-gray-800 ring-gray-600/20',
'planning-application' => 'bg-blue-100 text-blue-800 ring-blue-600/20',
'listed-building' => 'bg-amber-100 text-amber-800 ring-amber-600/20',
'conservation-area' => 'bg-emerald-100 text-emerald-800 ring-emerald-600/20',
'flood-risk-zone' => 'bg-cyan-100 text-cyan-800 ring-cyan-600/20',
'tree-preservation-zone' => 'bg-lime-100 text-lime-800 ring-lime-600/20',
'tree-preservation-order' => 'bg-lime-100 text-lime-800 ring-lime-600/20',
'article-4-direction-area' => 'bg-red-100 text-red-800 ring-red-600/20',
'article-4-direction' => 'bg-red-100 text-red-800 ring-red-600/20',
'brownfield-land' => 'bg-orange-100 text-orange-800 ring-orange-600/20',
'brownfield-site' => 'bg-orange-100 text-orange-800 ring-orange-600/20',
'scheduled-monument' => 'bg-stone-100 text-stone-800 ring-stone-600/20',
'site-of-special-scientific-interest' => 'bg-teal-100 text-teal-800 ring-teal-600/20',
'ancient-woodland' => 'bg-fuchsia-100 text-fuchsia-800 ring-fuchsia-600/20',
'heritage-at-risk' => 'bg-rose-100 text-rose-800 ring-rose-600/20',
'area-of-outstanding-natural-beauty' => 'bg-sky-100 text-sky-800 ring-sky-600/20',
'local-plan-boundary' => 'bg-indigo-100 text-indigo-800 ring-indigo-600/20',
'developer-agreement' => 'bg-violet-100 text-violet-800 ring-violet-600/20',
'community-infrastructure-levy-schedule' => 'bg-purple-100 text-purple-800 ring-purple-600/20',
'infrastructure-funding-statement' => 'bg-pink-100 text-pink-800 ring-pink-600/20',
'design-code-area' => 'bg-slate-100 text-slate-800 ring-slate-600/20',
];
@endphp
@if (isset($results['entities']) && count($results['entities']) > 0)
@endif
@if (isset($groupedEntities) && count($groupedEntities) > 0)
@php
// $badgeColors array was moved to the top for the filters
$hexColors = [
'conservation-area' => '#059669',
'listed-building' => '#d97706',
'green-belt' => '#16a34a',
'flood-risk-zone' => '#0891b2',
'tree-preservation-zone' => '#65a30d',
'tree-preservation-order' => '#65a30d',
'article-4-direction-area' => '#dc2626',
'article-4-direction' => '#dc2626',
'brownfield-land' => '#ea580c',
'brownfield-site' => '#ea580c',
'scheduled-monument' => '#57534e',
'site-of-special-scientific-interest' => '#0d9488',
'ancient-woodland' => '#c026d3',
'heritage-at-risk' => '#e11d48',
'area-of-outstanding-natural-beauty' => '#0284c7',
'planning-application' => '#2563eb',
'local-plan-boundary' => '#4f46e5',
'developer-agreement' => '#7c3aed',
'community-infrastructure-levy-schedule' => '#9333ea',
'infrastructure-funding-statement' => '#db2777',
'design-code-area' => '#475569',
];
@endphp
@foreach ($groupedEntities as $category => $entities)
{{ $category }}
@foreach ($entities as $entity)
@php
$datasetKey = $entity['dataset'] ?? 'unknown';
$badgeClass =
$badgeColors[$datasetKey] ??
'bg-gray-100 text-gray-800 ring-gray-600/20';
$readableDataset = ucwords(str_replace('-', ' ', $datasetKey));
@endphp
-
{{ $readableDataset }}
Ref:
{{ $entity['reference'] ?? 'N/A' }}
{{ $entity['name'] ?? 'Entity ' . $entity['entity'] }}
@if (isset($entity['description']))
{{ $entity['description'] }}
@endif
@foreach ($entity as $key => $value)
@if ($key === 'geometry')
@elseif(is_array($value))
-
{{ str_replace('_', ' ', $key) }}
-
{{ json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) }}
@else
-
{{ str_replace('_', ' ', $key) }}
@if (in_array($key, ['documentation-url', 'site-plan-url', 'planning-permission-history']) && filter_var($value, FILTER_VALIDATE_URL))
-
{{ $value }}
@else
-
{{ $value === '' || $value === null ? 'N/A' : $value }}
@endif
@endif
@endforeach
@endforeach
@endforeach
@if (isset($results['links']) && ($offset > 0 || isset($results['links']['next'])))
Showing {{ $offset + 1 }} - {{ $offset + count($results['entities']) }} of {{ number_format($results['count'] ?? count($results['entities'])) }}
Page {{ $page }}
@endif
@else
No entities found
We couldn't find any planning constraints matching your search
criteria.
@endif
@endif