Files
Verde-Web/app/Models/DumpsiteRelease.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

53 lines
1.3 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use MatanYadaev\EloquentSpatial\Objects\Point;
use MatanYadaev\EloquentSpatial\Traits\HasSpatial;
/**
* Records a load released at a dumpsite at the end of a trip. Populated
* by Module 10 (Trips & Timeline). Module 6 only creates the schema.
*/
class DumpsiteRelease extends Model
{
use HasFactory, HasSpatial;
protected $fillable = [
'trip_id',
'dumpsite_id',
'released_at',
'released_by_driver_id',
'weight_kg',
'waste_type_breakdown',
'gate_pass_number',
'dumpsite_attendant_name',
'photo_evidence_path',
'coordinates_at_release',
'notes',
];
protected function casts(): array
{
return [
'released_at' => 'datetime',
'weight_kg' => 'integer',
'waste_type_breakdown' => 'array',
'coordinates_at_release' => Point::class,
];
}
public function dumpsite(): BelongsTo
{
return $this->belongsTo(Dumpsite::class);
}
public function releasedByDriver(): BelongsTo
{
return $this->belongsTo(User::class, 'released_by_driver_id');
}
}