Files
Verde-Web/app/Models/RouteStop.php
admin de77503cdd feat(backend): complete Module 8 (routes)
routes + route_stops tables. Admin CRUD with stops submitted as an
ordered array (drag-reorder is client-side; sequence is array-index).
Cloning produces an inactive copy with -COPY-XXXX suffix. RouteCalculator
recomputes total_distance_km via ST_Distance_Sphere across stop
coordinates + dumpsite, and estimated_duration_minutes from dwell time
+ travel time at config-driven avg speed (default 25 km/h).
default_team_id stays nullable bigint until Module 9 adds the FK.

139 feature tests passing.

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

38 lines
776 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class RouteStop extends Model
{
use HasFactory;
protected $fillable = [
'route_id',
'drop_off_point_id',
'sequence',
'estimated_duration_at_stop_minutes',
];
protected function casts(): array
{
return [
'sequence' => 'integer',
'estimated_duration_at_stop_minutes' => 'integer',
];
}
public function route(): BelongsTo
{
return $this->belongsTo(Route::class);
}
public function dropOffPoint(): BelongsTo
{
return $this->belongsTo(DropOffPoint::class);
}
}