35 lines
1.5 KiB
PHP
35 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class TripResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->uuid,
|
|
'trip_number' => $this->trip_number,
|
|
'status' => $this->status,
|
|
'scheduled_date' => $this->scheduled_date?->toDateString(),
|
|
'scheduled_start_time' => $this->scheduled_start_time,
|
|
'actual_start_time' => $this->actual_start_time?->toIso8601String(),
|
|
'actual_end_time' => $this->actual_end_time?->toIso8601String(),
|
|
'dumpsite_arrival_time' => $this->dumpsite_arrival_time?->toIso8601String(),
|
|
'dumpsite_departure_time' => $this->dumpsite_departure_time?->toIso8601String(),
|
|
'total_load_kg' => $this->total_load_kg,
|
|
'is_detouring' => $this->is_detouring,
|
|
'route' => RouteResource::make($this->whenLoaded('route')),
|
|
'team' => CollectionTeamResource::make($this->whenLoaded('team')),
|
|
'truck' => TruckResource::make($this->whenLoaded('truck')),
|
|
'dumpsite' => DumpsiteResource::make($this->whenLoaded('dumpsite')),
|
|
'stops' => TripStopResource::collection($this->whenLoaded('stops')),
|
|
'timeline' => TripTimelineEventResource::collection($this->whenLoaded('timelineEvents')),
|
|
'notes' => $this->notes,
|
|
'created_at' => $this->created_at?->toIso8601String(),
|
|
];
|
|
}
|
|
}
|