Files
Verde-Web/app/Models/DropOffCapacityLog.php
admin 1150a518e8 feat(backend): complete Module 5 (drop-off points + auto-assign)
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>
2026-04-30 00:11:22 +08:00

39 lines
803 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class DropOffCapacityLog extends Model
{
use HasFactory;
protected $fillable = [
'drop_off_point_id',
'recorded_at',
'fill_percent',
'recorded_by_user_id',
'notes',
];
protected function casts(): array
{
return [
'recorded_at' => 'datetime',
'fill_percent' => 'integer',
];
}
public function dropOffPoint(): BelongsTo
{
return $this->belongsTo(DropOffPoint::class);
}
public function recordedBy(): BelongsTo
{
return $this->belongsTo(User::class, 'recorded_by_user_id');
}
}