trips, trip_stops, trip_timeline_events. Admin: schedule/show/cancel. Driver: start, arrive/depart/skip stops, report incident, arrive at dumpsite, release load (creates dumpsite_release row + tallies trip load), complete. Every action writes a typed timeline event with GPS. Trip number auto-generated TRIP-YYYYMMDD-NNN. Promotes dumpsite_releases.trip_id to a real FK now that trips exists. 148 feature tests passing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
31 lines
966 B
PHP
31 lines
966 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class TripTimelineEventResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'event_type' => $this->event_type,
|
|
'event_at' => $this->event_at?->toIso8601String(),
|
|
'coordinates' => $this->coordinates ? [
|
|
'lat' => $this->coordinates->latitude,
|
|
'lng' => $this->coordinates->longitude,
|
|
] : null,
|
|
'recorded_by' => $this->whenLoaded('recordedBy', fn () => [
|
|
'id' => $this->recordedBy?->uuid,
|
|
'name' => $this->recordedBy?->full_name,
|
|
]),
|
|
'related_type' => $this->related_type,
|
|
'related_id' => $this->related_id,
|
|
'metadata' => $this->metadata,
|
|
'notes' => $this->notes,
|
|
];
|
|
}
|
|
}
|