drop_off_points (with SPATIAL INDEX on coordinates) +
drop_off_capacity_logs. Public nearby query via ST_Distance_Sphere
returns DOPs sorted by distance with distance_meters in payload.
Admin CRUD plus capacity-log endpoint. Household creation auto-assigns
to the nearest active DOP within 25km; resident can re-run the lookup
via POST /households/{uuid}/reassign-drop-off.
97 feature tests passing.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
37 lines
988 B
PHP
37 lines
988 B
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\DropOffPoint;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Str;
|
|
use MatanYadaev\EloquentSpatial\Objects\Point;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\DropOffPoint>
|
|
*/
|
|
class DropOffPointFactory extends Factory
|
|
{
|
|
protected $model = DropOffPoint::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'uuid' => (string) Str::uuid(),
|
|
'name' => fake()->company().' DOP',
|
|
'code' => 'DOP-'.strtoupper(Str::random(6)),
|
|
'coordinates' => new Point(14.6, 121.0, 4326),
|
|
'address_line' => fake()->streetAddress(),
|
|
'capacity_kg' => 1000,
|
|
'status' => DropOffPoint::STATUS_ACTIVE,
|
|
];
|
|
}
|
|
|
|
public function at(float $lat, float $lng): static
|
|
{
|
|
return $this->state(fn () => [
|
|
'coordinates' => new Point($lat, $lng, 4326),
|
|
]);
|
|
}
|
|
}
|