Files
Verde-Web/database/seeders/SampleDumpsitesSeeder.php
admin 474b1cfe0b feat(backend): complete Module 6 (dumpsites + geofence)
dumpsites table with both coordinates POINT and boundary_polygon
POLYGON (SRID 4326). Admin CRUD accepts boundary as a list of {lat,lng}
points; ring is auto-closed. Dumpsite::containsPoint() runs ST_Contains
for geofence checks (Module 10 will fire arrived_at_dumpsite from this).
dumpsite_releases schema in place — trip_id stays nullable bigint until
Module 10 adds the FK.

109 feature tests passing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-30 00:39:14 +08:00

63 lines
2.5 KiB
PHP

<?php
namespace Database\Seeders;
use App\Models\CityMunicipality;
use App\Models\Dumpsite;
use Illuminate\Database\Seeder;
use MatanYadaev\EloquentSpatial\Objects\LineString;
use MatanYadaev\EloquentSpatial\Objects\Point;
use MatanYadaev\EloquentSpatial\Objects\Polygon;
/**
* Sample dumpsite for development. Real Payatas / Rizal MRF coordinates
* with a small rectangular geofence so geofence-trigger logic in Module
* 10 has something to fire against.
*/
class SampleDumpsitesSeeder extends Seeder
{
public function run(): void
{
$qc = CityMunicipality::where('code', 'QC')->first();
// Old Payatas dumpsite area (closed in real life — used here as a
// sample only). Centered at ~14.7155, 121.1083.
$center = ['lat' => 14.7155, 'lng' => 121.1083];
$half = 0.0035; // ~390m at this latitude
$boundaryPoints = [
new Point($center['lat'] - $half, $center['lng'] - $half, 4326),
new Point($center['lat'] - $half, $center['lng'] + $half, 4326),
new Point($center['lat'] + $half, $center['lng'] + $half, 4326),
new Point($center['lat'] + $half, $center['lng'] - $half, 4326),
new Point($center['lat'] - $half, $center['lng'] - $half, 4326),
];
Dumpsite::updateOrCreate(
['code' => 'DS-PAYATAS-01'],
[
'name' => 'Payatas Sanitary Landfill (sample)',
'address_line' => 'Payatas, Quezon City',
'city_municipality_id' => $qc?->id,
'coordinates' => new Point($center['lat'], $center['lng'], 4326),
'boundary_polygon' => new Polygon([new LineString($boundaryPoints)], 4326),
'accepted_waste_types' => ['general', 'biodegradable', 'residual'],
'operating_hours' => [
'mon' => ['open' => '06:00', 'close' => '22:00'],
'tue' => ['open' => '06:00', 'close' => '22:00'],
'wed' => ['open' => '06:00', 'close' => '22:00'],
'thu' => ['open' => '06:00', 'close' => '22:00'],
'fri' => ['open' => '06:00', 'close' => '22:00'],
'sat' => ['open' => '06:00', 'close' => '18:00'],
'sun' => null,
],
'capacity_tons' => 5000,
'permit_number' => 'DENR-NCR-SAMPLE-2026',
'contact_person' => 'Site Manager',
'contact_phone' => '+63281234567',
'status' => Dumpsite::STATUS_ACTIVE,
],
);
}
}