feat: update barangay management and dashboard roles

- Created dashboard-router to separate LGU and Super Admin landing pages
- Added Barangays and LGUs statistical cards to Super Admin dashboard
- Moved LGU Management to Areas group in sidebar and added API Docs link
- Removed geofence spatial validation (ST_Contains) for Barangay creation in both LGU and Super Admin controllers to allow flexible boundaries
This commit is contained in:
Developer
2026-07-07 10:32:38 +08:00
parent ee72cd7211
commit aaa5058249
7 changed files with 43 additions and 67 deletions

View File

@@ -55,20 +55,7 @@ class AdminBarangayController extends ApiController
$boundary = $this->buildPolygon($data['boundary']);
$centroid = $this->calculateCentroid($boundary);
if ($tenant->boundary_polygon) {
$isContained = DB::selectOne(
'SELECT ST_Contains(boundary_polygon, ST_GeomFromText(?, 4326, \'axis-order=long-lat\')) as contained FROM tenants WHERE id = ?',
[$boundary->toWkt(), $tenant->id]
);
if (! $isContained || ! $isContained->contained) {
return $this->fail(
'The drawn Barangay boundary must lie completely within your LGU boundary.',
['boundary' => ['The Barangay boundary is outside your LGU border.']],
422
);
}
}
// Spatial validation check removed as per user request
// Code auto-generation if empty
$city = CityMunicipality::findOrFail($cityId);
@@ -130,20 +117,7 @@ class AdminBarangayController extends ApiController
$boundary = $this->buildPolygon($data['boundary']);
$centroid = $this->calculateCentroid($boundary);
if ($tenant->boundary_polygon) {
$isContained = DB::selectOne(
'SELECT ST_Contains(boundary_polygon, ST_GeomFromText(?, 4326, \'axis-order=long-lat\')) as contained FROM tenants WHERE id = ?',
[$boundary->toWkt(), $tenant->id]
);
if (! $isContained || ! $isContained->contained) {
return $this->fail(
'The drawn Barangay boundary must lie completely within your LGU boundary.',
['boundary' => ['The Barangay boundary is outside your LGU border.']],
422
);
}
}
// Spatial validation check removed as per user request
// Code auto-generation if empty
$city = CityMunicipality::findOrFail($cityId);

View File

@@ -52,24 +52,7 @@ class SuperAdminBarangayController extends ApiController
$boundary = $this->buildPolygon($data['boundary']);
$centroid = $this->calculateCentroid($boundary);
// Spatial validation check
$cityId = $data['city_municipality_id'];
$tenant = Tenant::where('city_municipality_id', $cityId)->first();
if ($tenant && $tenant->boundary_polygon) {
$isContained = DB::selectOne(
'SELECT ST_Contains(boundary_polygon, ST_GeomFromText(?, 4326, \'axis-order=long-lat\')) as contained FROM tenants WHERE id = ?',
[$boundary->toWkt(), $tenant->id]
);
if (! $isContained || ! $isContained->contained) {
return $this->fail(
'The drawn Barangay boundary must lie completely within the LGU/Municipality boundary.',
['boundary' => ['The Barangay boundary is outside the LGU border.']],
422
);
}
}
// Spatial validation check removed as per user request
// Code auto-generation if empty
$city = CityMunicipality::findOrFail($cityId);
@@ -120,24 +103,7 @@ class SuperAdminBarangayController extends ApiController
$boundary = $this->buildPolygon($data['boundary']);
$centroid = $this->calculateCentroid($boundary);
// Spatial validation check
$cityId = $data['city_municipality_id'];
$tenant = Tenant::where('city_municipality_id', $cityId)->first();
if ($tenant && $tenant->boundary_polygon) {
$isContained = DB::selectOne(
'SELECT ST_Contains(boundary_polygon, ST_GeomFromText(?, 4326, \'axis-order=long-lat\')) as contained FROM tenants WHERE id = ?',
[$boundary->toWkt(), $tenant->id]
);
if (! $isContained || ! $isContained->contained) {
return $this->fail(
'The drawn Barangay boundary must lie completely within the LGU/Municipality boundary.',
['boundary' => ['The Barangay boundary is outside the LGU border.']],
422
);
}
}
// Spatial validation check removed as per user request
// Code auto-generation if empty
$city = CityMunicipality::findOrFail($cityId);