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>
43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Dumpsite;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Str;
|
|
use MatanYadaev\EloquentSpatial\Objects\LineString;
|
|
use MatanYadaev\EloquentSpatial\Objects\Point;
|
|
use MatanYadaev\EloquentSpatial\Objects\Polygon;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Dumpsite>
|
|
*/
|
|
class DumpsiteFactory extends Factory
|
|
{
|
|
protected $model = Dumpsite::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
$lat = 14.7;
|
|
$lng = 121.1;
|
|
$half = 0.003;
|
|
|
|
return [
|
|
'uuid' => (string) Str::uuid(),
|
|
'name' => fake()->city().' Dumpsite',
|
|
'code' => 'DS-'.strtoupper(Str::random(6)),
|
|
'address_line' => fake()->streetAddress(),
|
|
'coordinates' => new Point($lat, $lng, 4326),
|
|
'boundary_polygon' => new Polygon([new LineString([
|
|
new Point($lat - $half, $lng - $half, 4326),
|
|
new Point($lat - $half, $lng + $half, 4326),
|
|
new Point($lat + $half, $lng + $half, 4326),
|
|
new Point($lat + $half, $lng - $half, 4326),
|
|
new Point($lat - $half, $lng - $half, 4326),
|
|
])], 4326),
|
|
'capacity_tons' => 1000,
|
|
'status' => Dumpsite::STATUS_ACTIVE,
|
|
];
|
|
}
|
|
}
|